So I am trying to build a small object detector using a light sensor with an LED pointing at it so when an object passes between them the light dims and the sensor reaches a threshold. Then some LED lights go on. This would need to be in a while loop to keep in running. Every time time I try to use it get errors like crazy.
I don’t know much about coding and this is rather confusing to me. I keep getting errors dealing with the brackets and such.
File “C:\Users\Student.C105-10\Downloads\wrong.c” compiled on Nov 24 2014 09:18:39 Warning:Substituting similar variable ‘SensorValue’ for ‘sensorValue’. Check spelling and letter case. Error:Missing ‘(’ before ‘{’ Warning:’;’ expected before ‘}’. Automatically inserted by compiler Warning:Meaningless statement – no code generated Warning:Substituting similar variable ‘SensorValue’ for ‘sensorValue’. Check spelling and letter case. Error:Undefined variable ‘threshold’. ‘short’ assumed. Warning:Meaningless statement – no code generated Warning:Substituting similar variable ‘SensorValue’ for ‘sensorValue’. Check spelling and letter case. Warning:Symbol ‘wait10Msec’ is ‘deprecated’ definition. There may be alternate symbol with equivalent functionality. Error:Internal Compiler: Unexpected use of proc ‘wait10Msec’ in an expression Error:Procedure ‘wait10Msec’ is invalid syntax at this point Warning:Missing ‘;’ has been automatically inserted by compiler Warning:Meaningless statement – no code generated Warning:Substituting similar variable ‘SensorValue’ for ‘sensorValue’. Check spelling and letter case. Warning:Missing ‘;’ has been automatically inserted by compiler Warning:Meaningless statement – no code generated Warning:Substituting similar variable ‘SensorValue’ for ‘sensorValue’. Check spelling and letter case. Warning:’;’ expected before ‘}’. Automatically inserted by compiler Warning:Meaningless statement – no code generated
I am at a loss with coding and I don’t have time to do all the fixing myself. Thanks to anyone who helps.
should be like this to loop around this section forever:
while(true)
{
/// rest of code goes here
}
Next, you use a conditional check as a statement… I am not exactly sure what you are trying to do. You can set a sensor to a specific value but you can’t tell the computer to make a value greater than another.
sensorValue[in1] > threshold;
That line should be within an if or while statement itself… Notice the brackets for when the condition trips, I go do this.
if(sensorValue[in1] > threshold)
{
// some code that knows what I want to do when the sensor trips
}
Next the wait is a function call and needs an argument to wait a specific number of milliseconds. You also forgot the semicolon so the compiler kept on going to the next line jamming all the text together as one line.
Thank you. I am trying to make a ciggarette disposal that flashes lights to reduced ciggarette littler. So that is why I need the code to always be running.