Thursday, February 7, 2013

Introduction to Arduino Programming


Here is a program which upon start-up displays "I'm working". Then after 1.5 seconds counts by fives to thirty at which point the counter is set to 0 and it starts again:

int data;

void setup() {
 
  Serial.begin(9600);
  Serial.println("I'm working");
  delay(1500);
  data = 0;
}

void loop() {

 data +=5;
 Serial.print("Count by fives  ");
 Serial.println(data);
 delay(500);

 if(data==30){
  data=0;
 }
}

Here is an example of it working:
 

No comments:

Post a Comment