Show Posts
Pages: 1 [2]
16  Using Arduino / Programming Questions / Re: Need help with analog out to led's SECOND TRY on: August 11, 2012, 01:56:27 am
Thanks all
Got it working and learned a lot, picky program
17  Using Arduino / Programming Questions / Need help with analog out to led's SECOND TRY on: August 11, 2012, 01:30:00 am
I don't understand why so many errors
forum_3:-1: error: expected unqualified-id before numeric constant
forum_3:2: error: 'VOID' does not name a type
forum_3:3: error: 'CONST' does not name a type
forum_3:4: error: 'CONST' does not name a type
forum_3:5: error: 'CONST' does not name a type
forum_3:6: error: 'CONST' does not name a type
forum_3:7: error: 'CONST' does not name a type
forum_3:8: error: 'CONST' does not name a type
forum_3:9: error: 'CONST' does not name a type
forum_3:10: error: 'CONST' does not name a type
forum_3:11: error: 'CONST' does not name a type
forum_3:25: error: 'VOID' does not name a type

Thanks for all the replies


CODE

// These constants won't change:
CONST INT ANALOGPIN  = 0;    // pin that the sensor is attached to
CONST INT LEDPIN1 = 2;       // pin that the LED is attached to yellow
CONST INT LEDPIN2 = 3;       // pin that the LED is attached to green
CONST INT LEDPIN3 = 4;        // pin that the LED is attached to blue
CONST INT LEDPIN4 = 5;        //  red
CONST INT THRESHOLD1 = 15;   // yellow led
CONST INT THRESHOLD2 = 25;  // green led
CONST INT THRESHOLD3 = 50;  // blue led
CONST INT THRESHOLD4 = 75  // red led

void setup() {
  // initialize the LED pinS as an output:
  PINMODE ledPin1, (OUTPUT); // yellow
  PINMODE ledpin2,(OUTPUT); //green
  PINMODE ledPin3, (OUTPUT);  //blue
  PINMODE ledPin4, (OUTPUT);  //red


  // initialize serial communications:
  SERIAL.BEGIN(9600);
}

VOID LOOP() {
  // read the value of the potentiometer:
  INT ANALOGVALUE = ANALOGREAD(ANALOGPIN);

  IF (ANALOGVALUE > THRESHOLD1)           // yellow
    DIGITALWRITE(LEDPIN1, HIGH);
  ELSE
    DIGITALWRITE(LEDPIN1,LOW);


  IF (ANALOGVALUE > THRESHOLD2)             //green       
    DIGITALWRITE(LEDPIN2, HIGH);           
  ELSE
    DIGITALWRITE(LEDPIN2,LOW);             


  IF (ANALOGVALUE > THRESHOLD3)              //blue
    DIGITALWRITE (LEDPIN3, HIGH);
  ELSE
    DIGITALWRITE(LEDPIN3,LOW);


  IF (ANALOGVALUE > THRESHOLD4)             // red
    DIGITALWRITE(LEDPIN4, HIGH);
  ELSE
    DIGITALWRITE(LEDPIN4, LOW);


  // print the analog value:
  SERIAL.PRINTLN(ANALOGVALUE);
  delay(10);        // delay in between reads for stability
}

Pages: 1 [2]