system
August 15, 2013, 9:01pm
1
Hi all
I am using a lm35dz to send temp to serial through adruino, The code I have modified from someone else gives this error.
Expected unqualified-id before ' { ' token
float tempC;
int tempPin = 0;
int led = 13;
int val = 25;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop()
{
tempC=analogRead(tempPin);
tempC=(5.0*tempC*100.0)/1024.0;
Serial.println((byte)tempC);
delay(1000);
}
{
if (val = >++);
digitalWrite(led, HIGH);
}
Can some one please advise where I am going wrong here.
jackwp
August 15, 2013, 9:05pm
2
{
if (val = >++);
digitalWrite(led, HIGH);
}
{
if (val = >++);
digitalWrite(led, HIGH);
}
You have code here outside a function. You can't do that. The "loop" function ended a couple of lines earlier at the curly brace.
What is this supposed to do?
if (val = >++);
Pete
Oh yeah, about three things wrong with this line:
if (val = >++);
system
August 15, 2013, 9:17pm
6
Thanks guys, think I understand now.
{
tempC=analogRead(tempPin);
tempC=(5.0*tempC*100.0)/1024.0;
Serial.println((byte)tempC);
delay(1000);
if (val > 25) digitalWrite(led, HIGH);
}
system
August 15, 2013, 9:30pm
7
Well, atleast it compiles now due to a few changes, but, still will not flash the led on pin 13
float tempC;
int tempPin = 0;
int ledPin = 13;
int val = 25;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
tempC=analogRead(tempPin);
tempC=(5.0*tempC*100.0)/1024.0;
Serial.println((byte)tempC);
delay(1000);
if (val > 26) digitalWrite(13, HIGH);
}
Not surprised. You only ever turn the pin HIGH, but never LOW.
In order for the LED to flash it must turn on and off. I don't see any code to turn it off, or do you mean it never turns on ?
system
August 15, 2013, 9:42pm
10
never turns on but I have tried again with this. and still no good even though it compiles.
float tempC;
int tempPin = 0;
int led = 13;
int val = 25;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop()
{
tempC=analogRead(tempPin);
tempC=(5.0*tempC*100.0)/1024.0;
Serial.println((byte)tempC);
delay(1000);
if (val > 26) digitalWrite(13, HIGH);
else digitalWrite(13, LOW);
}
system
August 15, 2013, 9:49pm
11
I think I have it now.
float tempC;
int tempPin = 0;
int led = 13;
//int val = 25;
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop()
{
tempC=analogRead(tempPin);
tempC=(5.0*tempC*100.0)/1024.0;
Serial.println((byte)tempC);
delay(1000);
if (tempC > 26) digitalWrite(13, HIGH);
else digitalWrite(13, LOW);
}
now if i warm the sensor, the led lights.
Jesus C is hard, only been learning it for 4 hours now!!!
Thanks for your help guys.