simple robot suing asp.net and arduino.
#include <EEPROM.h>char val; // Data received from the serial port int motorPin1 =2; int motorPin2 =3; int motorPin3 =4; int motorPin4 =5; int addr = 0; // start reading from the first byte (address 0) of the EEPROM int address = 0; byte value; void setup() { pinMode(motorPin1, OUTPUT); // Set pin as OUTPUT pinMode(motorPin2, OUTPUT); // Set pin as OUTPUT pinMode(motorPin3, OUTPUT); // Set pin as OUTPUT pinMode(motorPin4, OUTPUT); // Set pin as OUTPUT Serial.begin(9600); // Start serial communication at 9600 bps } void loop() { if (Serial.available()) { // If data is available to read, val = Serial.read(); // read it and store it in val } if (val == 'L') { // If L was received digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, HIGH); digitalWrite(motorPin3, HIGH); digitalWrite(motorPin4, LOW); EEPROM.write(addr, 11); // advance to the next address. there are 512 bytes in // the EEPROM, so go back to 0 when we hit 512. addr = addr + 1; if (addr == 512) addr = 0; delay(50); } if (val == 'R') { // If R was received digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, HIGH); EEPROM.write(addr, 10); // advance to the next address. there are 512 bytes in // the EEPROM, so go back to 0 when we hit 512. addr = addr + 1; if (addr == 512) addr = 0; delay(50); } if (val == 'B') { // If B was received digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, HIGH); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, HIGH); EEPROM.write(addr, 01); // advance to the next address. there are 512 bytes in // the EEPROM, so go back to 0 when we hit 512. addr = addr + 1; if (addr == 512) addr = 0; delay(50); } if (val == 'F') { // If F was received digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, HIGH); digitalWrite(motorPin4, LOW); EEPROM.write(addr, 00); // advance to the next address. there are 512 bytes in // the EEPROM, so go back to 0 when we hit 512. addr = addr + 1; if (addr == 512) addr = 0; delay(50); } if (val == 'S') { // If F was received digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, LOW); EEPROM.write(addr, 100); // advance to the next address. there are 512 bytes in // the EEPROM, so go back to 0 when we hit 512. addr = addr + 1; if (addr == 512) addr = 0; } if( val == 'R') { value = EEPROM.read(address); if (value == 00)//fwrd { digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, HIGH); digitalWrite(motorPin4, LOW); delay(50); } if (value == 01)//bckwrd { digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, HIGH); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, HIGH); delay(50); } if (value == 10)//right { digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, HIGH); delay(50); } if (value == 11)//left { digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, HIGH); digitalWrite(motorPin3, HIGH); digitalWrite(motorPin4, LOW); delay(50); } if (value == 100)// stop { digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, LOW); } address = address + 1; // there are only 512 bytes of EEPROM, from 0 to 511, so if we're // on address 512, wrap around to address 0 if (address == 512) address = 0; delay(500); } }circuit diagram :
![[IMG]](proxy.php?image=http%3A%2F%2Fi54.tinypic.com%2Fzv1z7p.png&hash=bf631aceb0021a8220aa089c5c44603b)
pcb :
![[IMG]](proxy.php?image=http%3A%2F%2Fi53.tinypic.com%2F2i9saog.jpg&hash=0f7d38f55ec4e7f39636df0a5283ae21)
browser window:
![[IMG]](proxy.php?image=http%3A%2F%2Fi55.tinypic.com%2F2imaxe8.jpg&hash=65e64f09d85b6ce552e1ce2c5aec8e4a)
/////////////////<3<3<3//////////////////