Tuesday, 1 August 2017

Training Tuesday #14 Arduino Basics Blink

Good afternoon folks welcome to another Training Tuesday this week we will cover how to program Arduino 



Tools or items needed

Arduino or clone board 


Step one 

This example uses the built-in LED that most Arduino and Genuino boards have. This LED is connected to a digital pin and its number may vary from board type to board type. To make your life easier, we have a constant that is specified in every board descriptor file. This constant is LED_BUILTIN and allows you to control the built-in LED easily. 

Step two

After you build the circuit plug your Arduino or Genuino board into your computer, start the Arduino Software (IDE) and enter the code below. You may also load it from the menu File/Examples/01.Basics/Blink . The first thing you do is to initialize LED_BUILTIN pin as an output pin with the line
pinMode(LED_BUILTIN, OUTPUT);
In the main loop, you turn the LED on with the line:
digitalWrite(LED_BUILTIN, HIGH);
This supplies 5 volts to the LED anode. That creates a voltage difference across the pins of the LED, and lights it up. Then you turn it off with the line:
digitalWrite(LED_BUILTIN, LOW);
That takes the LED_BUILTIN pin back to 0 volts, and turns the LED off. In between the on and the off, you want enough time for a person to see the change, so the delay() commands tell the board to do nothing for 1000 milliseconds, or one second. When you use the delay() command, nothing else happens for that amount of time.

What have we learned 

 Once you've understood the basic examples, check out the BlinkWithoutDelay example to learn how to create a delay while doing other things.
Once you've understood this example, check out the DigitalReadSerial example to learn how read a switch connected to the board.


Don't forget to check out the daily dobby on social media Facebook   Twitter 


Thanks for taking the time to read this if you liked what you've read then please check back tomorrow after 17.00bst for another update thanks again. Dobby 

No comments:

Post a Comment

dobby repairs

Hi everyone I know that I haven't posted on here for quite some time  I probably won't be posting on here again for a while but I wa...

Total Pageviews