In the following code, the while loop only runs once, then stops?
//declare variables
int TX_LED = 3;
int RX_LED = 4;
int LC_LED = 5;
int LC_IN = 0;
int AB_IN = 1;
int MB_IN = 3;
int AMP_RELAY = 6;
int loadcell;
int ampbatt;
int mainbatt;
int compread = -1;
int compCONNECT;
int count = 0;
void setup()
{
Serial.begin(9600); //Begin arduino-computer serial communication at 9600baud.
KeithRB:
Also, the semi-colon after the while statement is what the while loop "sees" as the loop body. remove it.
Good catch.
A couple of improvements:
int TX_FLASH(int time)
{
digitalWrite(TX_LED, HIGH); //turn on TX_LED
delay(time); //wait TIME
digitalWrite(TX_LED, LOW); //turn off TX_LED
}
int RX_FLASH(int time)
{
digitalWrite(RX_LED, HIGH); //turn on RX_LED
delay(time); //wait TIME
digitalWrite(RX_LED, LOW); //turn off RX_LED
}
int LC_FLASH(int time)
{
digitalWrite(LC_LED, HIGH); //turn on LC_LED
delay(time); //wait TIME
digitalWrite(LC_LED, LOW); //turn off LC_LED
}
Can be reduced to:
void FLASH_SOMETHING(int led, unisgned long time)
{
digitalWrite(led, HIGH);
delay(time); //wait TIME
digitalWrite(led, LOW);
}
if (compread > 48)
I gather you aren't sending it 48, you're sending it '1', '2', '3', etc.? Functionally it's the same, but this is more clear as to your intentions:
if (compread > '0')
count = count + 1;
The language is called C++. Feel free to use such operator:
Thanks for the responses. Was very pressed for time and totally forgot about code snippets Also, very new to C++, very used to VB.net, so I was used to:count = count + 1 Will go through and change that. Arrch, thanks for bring those to my attention. Its works now