Arduino 102

150329 Arduino ProjectsFinally another chance to spend some time learning my new Freetronics Eleven (aka. Arduino). Some of the basics are starting to sink in, the project guide that came with the kit is actually quite good at explaining the reasons why certain things must be done for both hardware and software. The projects pictured above are:

  1. Project #4: using a light sensor to dim an LED.
  2. Project #6: controlling a servo.
  3. Project #6 Customised: adding an LED that turns on when the servo spins in one direction, and off in the other.

Again not the most exciting projects, but at the moment it’s all about making sense of this ‘new world.’ I have included the code for the custom project #6 if you want to build it yourself.

int led = 13;
int delaytime=5;
int angle=0;

#include <Servo.h>
Servo myservo;

void setup()
{
  myservo.attach(11);
  pinMode(led, OUTPUT);
}

void loop()
{
  while (angle <=180)
  {
      myservo.write(angle);
      delay(delaytime);
      angle = angle + 1;
      digitalWrite(led, HIGH);
  }
  while (angle > 0)
  {
      myservo.write(angle);
      delay(delaytime);
      angle = angle - 1;
      digitalWrite(led, LOW);
  }
}

Happy hacking!

– Posted by James Novak

2 thoughts on “Arduino 102

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s