Some (simple??) stuff. Just a weird project I don't understand.

I'm pretty new to coding, and I'm in an engineering class where we've just started working with Arduino. The project I'm working on is basically a heat sensor that works as a 'Love-O-Meter.' It's pretty dumb and simple but I'll put the list of errors below.

14:15: error: stray '\342' in program
14:16: error: stray '\200' in program
14:17: error: stray '\234' in program
14:32: error: stray '\342' in program
14:33: error: stray '\200' in program
14:34: error: stray '\234' in program
18:15: error: stray '\342' in program
18:16: error: stray '\200' in program
18:17: error: stray '\234' in program
18:27: error: stray '\342' in program
18:28: error: stray '\200' in program
18:29: error: stray '\234' in program
In function 'void loop()':
14:18: error: 'Sensor' was not declared in this scope
14:18: note: suggested alternative: 'perror'
18:18: error: expected primary-expression before ',' token
18:20: error: 'Volts' was not declared in this scope
exit status 1

const int sensorPin = A0;
const float baselineTemp = 20.0;
void setup(){
 Serial.begin(9600); // open a serial port
 for(int pinNumber = 2; pinNumber<5; pinNumber++){
 pinMode(pinNumber,OUTPUT);
 digitalWrite(pinNumber, LOW);
 }
}
void loop(){
 int sensorVal = analogRead(sensorPin);
 Serial.print(“Sensor Value: “);
 Serial.print(sensorVal);
  // convert the ADC reading to voltage
 float voltage = (sensorVal/1024.0) * 5.0;
 Serial.print(“, Volts: “);
 Serial.print(voltage);
 Serial.print(", degrees C:");
 // convert the voltage to temperature in degrees
 float temperature = (Volts - 0.5) * 100;
 Serial.println(temperature);
  if (temperature < baselineTemp){
 digitalWrite(2, LOW);
 digitalWrite(3, LOW);
 digitalWrite(4, LOW);
     }else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
 digitalWrite(2, HIGH);
 digitalWrite(3, LOW);
 digitalWrite(4, LOW);
 }else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6){
 digitalWrite(2, HIGH);
 digitalWrite(3, HIGH);
 digitalWrite(4, LOW);
 }else if(temperature >= baselineTemp+6){
 digitalWrite(2, HIGH);
 digitalWrite(3, HIGH);
 digitalWrite(4, HIGH);
 }
 delay(1);
}

[tt]​[/tt]

Hi,
Welcome to the forum.
Where did you get the code?

What model Arduino are you using?

I have tried to compile it, where does the variable Volts come from?

Thanks.. Tom.. :slight_smile:

TomGeorge:
Hi,
Welcome to the forum.
Where did you get the code?

What model Arduino are you using?

I have tried to compile it, where does the variable Volts come from?

Thanks.. Tom.. :slight_smile:

Ah, it's some scuffed up code my teacher wrote and then told us to fix. I tried but I don't get it. Not sure where volts came from. I'm using the Uno though!
Thank you!

Those stray characters are the sort of thing that shows up when you copy-paste code from a web page or PDF etc.

Blackfin:
Those stray characters are the sort of thing that shows up when you copy-paste code from a web page or PDF etc.

https://armandoramos2145.weebly.com/uploads/8/7/7/9/87794446/uwu.pdf

Thank you so much! :cry: I really appreciate it!

Incidentally, if you copy the code that you posted here, the website will have removed the stray characters.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.