Let's Make Robots!

coding help

i'm done making a robot hand fr my school fair. it uses 1 flex sensor and 1 servo...i found a code fr it on itp...this is fr arduino...but sadly something happened and my fake arduino mega burnt out....now i have 2 do it on my picaxe

the arduino code is this


Updated 08 Sep 2009
 by Rory Nugent
 Created 20 Jan 2009
 by Tom Igoe

 #include <Servo.h>      // include the servo library

 Servo servoMotor;       // creates an instance of the servo object to control a servo

 int analogPin = 0;      // the analog pin that the sensor is on
 int analogValue = 0;    // the value returned from the analog sensor

 int servoPin = 2;       // Control pin for servo motor. As of Arduino 0017, can be any pin

 void setup() { 
   servoMotor.attach(servoPin);  // attaches the servo on pin 2 to the servo object

 void loop() 
   analogValue = analogRead(analogPin);                 // read the analog input (value between 0 and 1023)
   analogValue = map(analogValue, 0, 1023, 0, 179);     // map the analog value (0 - 1023) to the angle of the servo (0 - 179)
   servoMotor.write(analogValue);                       // write the new mapped analog value to set the position of the servo

the competition is 2morro so plz help me with the code....im sure it is simple but im a noob..help will be really appreciated


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Please read the rules