Week 6: Embedded Programming

PCB at work:

Group_Assignment

For Embedded programming I played with the push button and two LEDs on my board.

I went through a lot of documents and XIAO ESP32 C3 datasheet to understand the ins and outs of working with the board. I got understand a fair amount of details on it's structure and pins, I only got a clue how to get it to do something when I actually tried a few programs.

Toggle Switch

The last program I tried was a toggle switch for the LED.

Most of the references/guides I followed were from Arduino Uno projects. I noticed that there is no big difference ESP32's programming and the Arduino board, I just had to adapt the codes to how the XIAO reads its pins.

To do the toggle swithc I basically had to figure out how to tell XIAO ESP32 to recognize one button press and turn that into a signal for the LED and keep it on even after the I let go of the button.

Since it's not very obvious to the board you want to break it down into different initial states and alternate/opposite states for both the button and the LED.

Ledstate=0 meaning you want the LED to be off when your program starts, because obviously you want to turn it on. Latter you will tell it to switch to ledstate=1 (It already knows that 1 and 0 means HIGH and LOW respectively) when it get's certain a signal/button from the button.

The signal the LED is waiting for is buttonOld and buttonNew which you use to preset the button siganls. ButtonNew being the current state and the buttonOld being the state before you pressed.

You basically want your board to read button value 0 and 1 and then switch on the LED, depicted the picture below.

Contact

Happy to receive your inquiries.

Location:

Kigali, Rwanda

Call:

+250 780 716 155