EasyManua.ls Logo

Keyestudio ESP32 - Page 120

Keyestudio ESP32
344 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
ESP32 Starter Kit
Code
/*
keyestudio ESP32 Inventor Learning Kit
Project 19.2 Dimming Lamp
http://www.keyestudio.com
*/
int led = 25; //Define LED to IO25
int pot = 34; //Define pot to IO34
void setup() {
// put your setup code here, to run once:
pinMode(led,OUTPUT); //Set LED pin to output
}
void loop() {
// put your main code here, to run repeatedly:
int value = analogRead(pot);
int led_val = map(value,0,4095,0,255); //Convert the range of potentiometer analog
˓value to the range we need
analogWrite(led,led_val);
}
116 Chapter 8. Arduino Tutorial

Table of Contents