Update of code to Beta 0.2
Main update is to syntax, as well as adding port selection for input/output.
Info at end of code - or send h from serial monitor.
Code part 1 :
//
//
// ACiD V0.3 (Beta)
//
// Arduino Control Desktop
//
// Drew Anderson - 2010 (24/4/10)
// Update 25/4/10
//
// Connect with any com program - I use this as a simple
// In/Out Handler for my VB6 programs - Easy protocol to
// implement.
//
// send x - reset to root menu
// send S - Ask for Digital port values 0=LOW 1=HIGH
//
// Then just parse the string to read port value
// (reads ALL ports 2 - 13)
//
// send x - reset to root menu
// send H - select WRITE HIGH menu
// send 3->0 or a,b or c - select port to set HIGH
//
// send x - reset to root menu
// send L - select WRITE LOW menu
// send 3->0 or a,b or c - select port to set LOW
//
// send x - reset to root menu
// send M - select MODE for PIN
// send N0. - Pin number (2 - 0 a,b,c)
// send the letter 'o' or 'i' for output or input
int level=0;
int tmp1=0;
int sinput=0;
int sinput2=0;
int sinput3=0;
int temp1 = 0;
int temp2 = 0;
int temp3 = 0;
int temp4 = 0;
int temp5 = 0;
int temp6 = 0;
int temp7 = 0;
int temp8 = 0;
int temp9 = 0;
int temp10 = 0;
int temp11 = 0;
int temp12 = 0;
int temp13 = 0;
int pm2 = 0 ;
int pm3 = 0 ;
int pm4 = 0 ;
int pm5 = 0 ;
int pm6 = 0 ;
int pm7 = 0 ;
int pm8 = 0 ;
int pm9 = 0 ;
int pm10 = 0 ;
int pm11 = 0 ;
int pm12 = 0 ;
int pm13 = 0 ;
char prts[]="0000000000000";
void setup()
{
Serial.begin(57600);
int x=0;
for(x=2;x<14;x++)
{
pinMode(x, OUTPUT);
}
//
// If you need to set any port to input then do it here
//
// pinMode(2, INPUT);
// pinMode(3, INPUT);
// pinMode(4, INPUT);
// pinMode(5, INPUT);
// pinMode(6, INPUT);
// pinMode(7, INPUT);
// pinMode(8, INPUT);
// pinMode(9, INPUT);
// pinMode(10, INPUT);
// pinMode(11, INPUT);
// pinMode(12, INPUT);
// pinMode(13, INPUT);
}
void loop()
{
if (Serial.available() > 0)
{
sinput=Serial.read();
// x - Reset to start Screen
if (sinput=='x')
{
level=0;
}
// M - Set the pinMode of the digital pin
if (sinput=='M')
{
level=7;
}
if (sinput=='L')
{
level=3;
}
if (sinput=='R')
{
level=1;
}
if (sinput=='H')
{
level=2;
}
if (sinput=='S')
{
level=4;
}
if (sinput=='h')
{
level=5;
}
if (sinput=='P')
{
level=6;
}
if (level==2)
{
if (sinput=='2')
{
digitalWrite(2, HIGH);
}
if (sinput=='3')
{
digitalWrite(3, HIGH);
}
if (sinput=='4')
{
digitalWrite(4, HIGH);
}
if (sinput=='5')
{
digitalWrite(5, HIGH);
}
if (sinput=='6')
{
digitalWrite(6, HIGH);
}
if (sinput=='7')
{
digitalWrite(7, HIGH);
} if (sinput=='8')
{
digitalWrite(8, HIGH);
} if (sinput=='9')
{
digitalWrite(9, HIGH);
}
if (sinput=='0')
{
digitalWrite(10, HIGH);
} if (sinput=='a')
{
digitalWrite(11, HIGH);
} if (sinput=='b')
{
digitalWrite(12, HIGH);
} if (sinput=='c')
{
digitalWrite(13, HIGH);
}
}
if (level==3)
{
if (sinput=='2')
{
digitalWrite(2, LOW);
}
if (sinput=='3')
{
digitalWrite(3, LOW);
}
if (sinput=='4')
{
digitalWrite(4, LOW);
}
if (sinput=='5')
{
digitalWrite(5, LOW);
}
if (sinput=='6')
{
digitalWrite(6, LOW);
}
if (sinput=='7')
{
digitalWrite(7, LOW);
} if (sinput=='8')
{
digitalWrite(8, LOW);
} if (sinput=='9')
{
digitalWrite(9, LOW);
}
if (sinput=='0')
{
digitalWrite(10, LOW);
} if (sinput=='a')
{
digitalWrite(11, LOW);
} if (sinput=='b')
{
digitalWrite(12, LOW);
} if (sinput=='c')
{
digitalWrite(13, LOW);
}
}
if (level==7)
{
if (sinput=='2')
{
sinput2='2';
}
if (sinput=='3')
{
sinput2='3';
}
if (sinput=='4')
{
sinput2='4';
}
if (sinput=='5')
{
sinput2='5';
}
if (sinput=='6')
{
sinput2='6';
}
if (sinput=='7')
{
sinput2='7';
}
if (sinput=='8')
{
sinput2='8';
}
if (sinput=='9')
{
sinput2='9';
}
if (sinput=='0')
{
sinput2='0';
}
if (sinput=='a')
{
sinput2='a';
}
if (sinput=='b')
{
sinput2='b';
}
if (sinput=='c')
{
sinput2='c';
}
if (sinput=='o')
{
sinput3='o';
}
if(sinput=='i')
{
sinput3='i';
}
if (sinput2=='2')
{
if (sinput3=='o')
{
pinMode(2, OUTPUT);
pm2 = 0;
}
if (sinput3=='i')
{
pinMode(2, INPUT);
pm2 = 1;
}
}
if (sinput2=='3')
{
if (sinput3=='o')
{
pinMode(3, OUTPUT);
pm3 = 0;
}
if (sinput3=='i')
{
pinMode(3, INPUT);
pm3 = 1;
}
}
if (sinput2=='4')
{
if (sinput3=='o')
{
pinMode(4, OUTPUT);
pm4 = 0;
}
if (sinput3=='i')
{
pinMode(4, INPUT);
pm4 = 1;
}
}
if (sinput2=='5')
{
if (sinput3=='o')
{
pinMode(5, OUTPUT);
pm5 = 0;
}
if (sinput3=='i')
{
pinMode(5, INPUT);
pm5 = 1;
}
}
if (sinput2=='6')
{
if (sinput3=='o')
{
pinMode(6, OUTPUT);
pm6 = 0;
}
if (sinput3=='i')
{
pinMode(6, INPUT);
pm6 = 1;
}
}
if (sinput2=='7')
{
if (sinput3=='o')
{
pinMode(7, OUTPUT);
pm7 = 0;
}
if (sinput3=='i')
{
pinMode(7, INPUT);
pm7 = 1;
}
}
if (sinput2=='8')
{
if (sinput3=='o')
{
pinMode(8, OUTPUT);
pm8 = 0;
}
if (sinput3=='i')
{
pinMode(8, INPUT);
pm8 = 1;
}
}
if (sinput2=='9')
{
if (sinput3=='o')
{
pinMode(9, OUTPUT);
pm9 = 0;
}
if (sinput3=='i')
{
pinMode(9, INPUT);
pm9 = 1;
}
}
if (sinput2=='0')
{
if (sinput3=='o')
{
pinMode(10, OUTPUT);
pm10 = 0;
}
if (sinput3=='i')
{
pinMode(10, INPUT);
pm10 = 1;
}
}
if (sinput2=='a')
{
if (sinput3=='o')
{
pinMode(11, OUTPUT);
pm11 = 0;
}
if (sinput3=='i')
{
pinMode(11, INPUT);
pm11 = 1;
}
}
if (sinput2=='b')
{
if (sinput3=='o')
{
pinMode(12, OUTPUT);
pm12 = 0;
}
if (sinput3=='i')
{
pinMode(12, INPUT);
pm12 = 1;
}
}
if (sinput2=='c')
{
if (sinput3=='o')
{
pinMode(13, OUTPUT);
pm13 = 0;
}
if (sinput3=='i')
{
pinMode(13, INPUT);
pm13 = 1;
}
}
}
if (level==6)
{
if (pm13 == 1)
{
prts[12]='1';
}
else
{
prts[12]='0';
}
if (pm12 == 1)
{
prts[11]='1';
}
else
{
prts[11]='0';
}
if (pm11 == 1)
{
prts[10]='1';
}
else
{
prts[10]='0';
}
if (pm10 == 1)
{
prts[9]='1';
}
else
{
prts[9]='0';
}
if (pm9 == 1)
{
prts[8]='1';
}
else
{
prts[8]='0';
}
if (pm8 == 1)
{
prts[7]='1';
}
else
{
prts[7]='0';
}
if (pm7 == 1)
{
prts[6]='1';
}
else
{
prts[6]='0';
}
if (pm6 == 1)
{
prts[5]='1';
}
else
{
prts[5]='0';
}
if (pm5 == 1)
{
prts[4]='1';
}
else
{
prts[4]='0';
}
if (pm4 == 1)
{
prts[3]='1';
}
else
{
prts[3]='0';
}
if (pm3 == 1)
{
prts[2]='1';
}
else
{
prts[2]='0';
}
if(pm2 ==1)
{
prts[1]='1';
}
else
{
prts[1]='0';
}
delay(10);
Serial.println(prts);
delay(10);
}
if(level==1)
{
for(tmp1=2;tmp1<14;tmp1++)
{
if (digitalRead(tmp1)==1)
{
Serial.print("Pin ");
if(tmp1<10)
{
Serial.print("0");
}
Serial.print(tmp1);
Serial.println(" is currently High.");
}
else
{
Serial.print("Pin ");
if(tmp1<10)
{
Serial.print("0");
}
Serial.print(tmp1);
Serial.println(" is currently Low.");
}
}
Serial.println(" ");
Serial.println("x. Return to First Screen");
}
if (level==2)
{
}
if (level==3)
{
}