1.3 Creating different led patterns and controlling them using push button switches interfacing with ESP32
1.3 Creating different led patterns and controlling them using push button switches interfacing with ESP32
• ESP32 board
• LEDs
• Switches
• 12V Adaptor
• Power jack
• USB Cable
• Jumper Wires
Hardware Procedure:
• LED & Switch in Development Board LED1, LED2, LED3, SW I/P1, SW1/P2 pins
connected to D13, D12, D14, D23, D22 pins of ESP32 board.
• Power jack is connected to the ESP32 board.
• USB connector is connected to ESP32 board and CPU.
• Connect the 12V power supply to development board.
• Upload corresponding program into ESP32 board
• Switch ON Power supply.
Software Procedure:
1. Click on Arduino IDE
2. Click on file
3. Click on New
4. Write a Program as per circuit Pin connections
5. Click on Save
6. Click on Verify
7. Click on tools select ESP32 board and select port.
8. Click on Upload the code into ESP32 board by using USB cable.
9. Go to tools click on serial plotter verify the output in graph format.
Code:
//char input;
void setup()
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(sw1, INPUT);
pinMode(sw2, INPUT);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
void loop()
if(digitalRead(sw1)==LOW)
{
digitalWrite(led1, HIGH);
delay(300);
digitalWrite(led1, LOW);
delay(300);
digitalWrite(led1, HIGH);
delay(400);
digitalWrite(led1, LOW);
delay(400);
digitalWrite(led2, HIGH);
delay(400);
digitalWrite(led2, LOW);
delay(400);
digitalWrite(led3, HIGH);
delay(400);
digitalWrite(led3, LOW);
delay(400);
if(digitalRead(sw2)==LOW)
digitalWrite(led3, HIGH);
delay(300);
digitalWrite(led3, LOW);
delay(300);
digitalWrite(led3, HIGH);
delay(400);
digitalWrite(led3, LOW);
delay(400);
digitalWrite(led2, HIGH);
delay(400);
digitalWrite(led2, LOW);
delay(400);
digitalWrite(led1, HIGH);
delay(400);
digitalWrite(led1, LOW);
delay(400);
Precautions: