We Speak PC
  • Home
  • Resources
  • Gallery

  •              Allen@wespeakpc.com
                 Call us: 972-704-5114

Arduino Programming and Electronics

Post Image

Project 1: Blinking light

PURPOSE:

A lot of things you do start with an idea, a lightbulb in your head.  You are going to bring out that bulb from your head and show the world you have an idea.

MATERIALS NEEDED:

Arduino board

Arduino USB Cable

Computer

THE PROJECT: (BLINK)

Plug in your arduino and let's start your first program.

1. Double-click the Arduino icon on your desktop.

2. Click on file, Save as , then give it the name Blink.

3. Copy the following that is in red only. (Remember to be exact. Even the smallest mistake might make your program not work).  We will break it down in grey (The stuff you don't have to write down ) When you open a new sketch, part of it is already there for you. you can delete it all and start fresh to avoid any confusion.

/* Anything between the symbols /* and */ or anything after the \\ symbol is considered a comment and ignored by the Arduino. You just need it for keeping track of what you do.*/


\\ My Project Name:  Blink
\\ What my project does: Makes my idea wink (or blink) at me by turning an light on and off


int led = 13;

//The arduino has a built in LED right on pin 13

\* Here we tell the Arduino that we are going to use pin 13. But instead of calling it 13 every time we are going to call it something we can remember what it was for. Since we are using an LED for that pin(connection) then we call it led . *\


void setup ( ) {

// Everything within these Brackets is in the setup area

// this part is only run once. Think of this where you set up your play area with everything you are going to use or do.

pinMode  (led, OUTPUT);

//This is where we tell the Arduino to use pin 13 as an output because we want to see what happens.


} /* END SETUP */


void loop (){

\\ this loop section is going to happen forever unless we make it stop.

digitalWrite (led, HIGH);

\\Turn the LED on

delay(500);

\\Leave it on for a little bit so we can see what happens

digitalWrite (led, LOW);

\\Turn LED off


delay(500);

\\Wait some time to make sure it turns off

}

/* END LOOP */

 

***********************
Now it is time to see if it works.  Click in the check mark on the top left. If there are any errors it will start pointing them out to you.  if you just can’t figure it out please let me know and I will help you out.  Once it says it is done, then click on the right arrow button next to it to copy your program from your computer to the Arduino board.

Activities:

  1. Can you adjust the program to stay on longer?
  2. Can you adjust the program to stay off longer?
  3. Can you make any changes to the program to make a different blinking pattern?