Introduction: Arduino IDE Using Dp32
Making an Arduino program
Step 1: Step 1: Start
First start up your Arduino IDE. A window like shown should pop up with basic code.
Step 2: Step 2: Check Tools
Secondly check to make sure that you have the correct board and port selected. This will be under the tools option. We are assuming that you have already unloaded your hex file into your board.
Step 3: Step 3: Writing Basic Code
Since assuming new to using Arduino, we are going to start we basic code and then made it a bit more complex. The following code is a simple push a button and an LED will turn on.
Step 4: Step 4: Running the Code
First you will click on the green check mark that is on the top left of the Arduino IDE to verify that your code works. Then when that is complete, you will press the green arrow right beside it to run/upload your code onto your Arduino. When complete, if you click on any of the buttons on your board, we will notice that one of the LEDs will light up. Pressing a different button will light up a different LED.
Step 5: Step 5: Upgrading Basic Code
Now since we got the basic, push button and turn an LED on, we will upgrade the code a bit to make it do a bit more. We will first change the top of our code so we have all 4 of our LEDs defined separately and we will also have a counter to keep track of the LEDs as shown.
Step 6: Step 6: Loop
Now we are going to change our IF statement so instead of a single LED turning on when a button is pressed, we are going to have a certain amount of LEDs turn on when you press a button. The first time you press a button, a single LED should turn on, pressing again will turn on a 2nd LED, then the 3rd and lastly the 4th so after 4 presses, all 4 LEDs should turn on and if you press again, the last 3 LEDs will turn off and start again from 1.
Step 7: Step 7: Running the Upgraded Code
Now when you run the code and try it, you will see that now the LEDs light up depending on how many times you can pressed the buttons. Pressing the buttons fast enough you will notice that the LEDs will looking like a loading bar that keeps looping. Now with these bits of basic code, you can easily play around with what the LEDs do when you press the buttons and how many buttons have been pressed. Play around and enjoy!
We have a be nice policy.
Please be positive and constructive.