Skip to content

Commit

Permalink
Modified the code after the initial prototype session.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgcastro committed Mar 12, 2015
1 parent 4f79903 commit 7fb7b0a
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions exandounamano.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,43 @@

#include <Servo.h>

int analogInputPin[6];
int sensorPin = 0;
int servoPin = 9;

int inputReading[6];
int inputReading;
int sensorThreshold = 100;

Servo handServo;
// Servo position in degrees.
int position;
int position = 0;

void setup()
{
handServo.attach(10);
// Init the servo output.
pinMode(servoPin, OUTPUT);
handServo.attach(servoPin);

position = 0;

for (int i=0;i<6;i++) {
analogInputPin[i] = i+1;
inputReading[i] = 0;
pinMode(analogInputPin[i], INPUT);
}

Serial.begin(9600);
// Init sensor input.
inputReading = 0;
pinMode(sensorPin, INPUT);
}

void loop()
{
for (int i=0;i<6;i++) {
inputReading[i] = analogRead(analogInputPin[i]);
}
// Read the input value.
inputReading = analogRead(sensorPin);

if (inputReading >= sensorThreshold) {
if (position == 0)
position = 180;
else
position = 0;

for (int i=0;i<1;i++) {
if (inputReading[i] >= 400) {
if (position == 0)
position = 180;
else
position = 0;
handServo.write(position);

handServo.write(position);
delay(1000);
}
// Wait for the servo to move.
delay(1000);
}

delay(100);
delay(50);
}

0 comments on commit 7fb7b0a

Please sign in to comment.