Pages: [1]   Go Down
Author Topic: Save Servo Position on EEPROM  (Read 679 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, i made a program to move servos whit android, it works well, but now i want to save sequences of movements, for example, move servo 1 to 180°, move servo 2 to 100°, etc. only using the android phone, i have a idea but i dont know if it is good, this is the code to do the movements in manual form:
[c
« Last Edit: March 23, 2013, 04:38:19 pm by Eduort » Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The EEPROM.write() writes only a byte.
http://arduino.cc/en/Reference/EEPROMWrite
But since a byte is 0...255 and the servo position is 0...180 it is okay.

Have you considered using a case statement ?

Code:
if (Serial.available() > 0) {         
  data = Serial.read();
}

switch (data) {
case 'X':
case 'x':
  EEPROM.write( 1, servo1 position);
  EEPROM.write( 2, servo2 position);         
  break;
case 'Y':
case 'y':
  pos1 = EEPROM.read(1);
  servo1.write(pos1);
  pos2 = EEPROM.read(2);
  servo1.write(pos2);         
  break;
default:
  break;
}
Logged

Pages: [1]   Go Up
Jump to: