Arduino – Controlling Things

This will start you off programming!

dilbert2666700071126

 

 

Light Emitting Diode (LED)

leddetail_tled

The Arduino Uno

arduino uno

 

 

Code to blink 1 Led

 (int=integer - a number , this next line is setting a variable ledPin (could be anything you want to call it) to a value)
int ledPin = 13;                // LED connected to digital pin 13

(void - means run and let it keep running, setup is telling the computer what it needs to know the pin and which direction)

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

(the body of the code, run and keep rerunning it - loop)
void loop()                     // run over and over again
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

 

Code to blink 2 LEDs

int redPin = 12;                  // Red LED connected to digital pin 12
int greenPin = 11;                // Green LED connected to digital pin 11

void setup()                      // run once, when the sketch starts
{
  pinMode(redPin, OUTPUT);        // sets the digital pin as output
  pinMode(greenPin, OUTPUT);      // sets the digital pin as output
}

void loop()                       // run over and over again
{
  digitalWrite(redPin, HIGH);     // sets the Red LED on
  digitalWrite(greenPin, HIGH);   // sets the Green LED on
  delay(500);                     // waits for half a second
  digitalWrite(redPin, LOW);      // sets the Red LED off
  digitalWrite(greenPin, LOW);    // sets the Green LED off
  delay(500);                     // waits for half a second
}

 

Power Transistors

Control bigger stronger components – motors, lights

power_transistor

 

They have a base, collector and emitter.

 

transistor power schemic

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

schematic motor

 

Instructible about controlling motors with an Arduino

 

More about the Arduino

Lady Adafruit