Friday, December 12, 2014

Fritzing and Arduino Code

The following is the final code for our project and the wiring.


#include <Servo.h>

Servo myservo;
int val;

void setup()
{
  Serial.begin(9600);
  myservo.attach(12);
  myservo.write(120);
}
void loop()
{
  Serial.println(analogRead(0));
  val = analogRead(0);
  
  if(val > 500)
  {
  myservo.write(60);
  delay(5000);
  myservo.write(120);
  while(1) { }
  }
  delay(1500);

Written by Brendan Ford

No comments:

Post a Comment