hi!
im new
i got this really big project, and then when i compile it, it gives me this:
Arduino: 1.8.5 (Windows 8), Board: "Arduino/Genuino Uno"
ultrasonicLightSensor:95: error: a function-definition is not allowed here before '{' token
{
^
ultrasonicLightSensor:100: error: a function-definition is not allowed here before '{' token
{
^
ultrasonicLightSensor:123: error: expected '}' at end of input
}
^
ultrasonicLightSensor:123: error: expected '}' at end of input
exit status 1
a function-definition is not allowed here before '{' token
my code: (really long!)
#include <neotimer.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
#define echoPin 6 // Echo Pin
#define trigPin 13 // Trigger Pin
#define SPEED_SOUND 58.2 //speed of sound
//buttonState = digitalRead(buttonPin);
int piezoPin = 3;
int duration = pulseIn(echoPin, HIGH);
int distance = duration / SPEED_SOUND;
int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
int buttonState = 0;
const int buttonPin = 2;
void UltrasoundSystem (void)
{
long duration, distance;
digitalWrite(trigPin, LOW);
delay(2);
digitalWrite(trigPin, HIGH);
delay(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration / SPEED_SOUND;
Serial.print("distance:");
Serial.println(distance);
Serial.println("/r");
delay(1000);
lcd.setCursor(10,0);
lcd.print(distance);
delay(200);
if (distance < 31)
{
Serial.println("too close!");
//lcd.setCursor(4,1);
//lcd.write("too close!");
//tone(piezoPin, 2200, 1000);
//delay(1000);
//lcd.clear();
}
}
void LightSystem (void)
{
int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
Serial.print("sensor value 1:");
Serial.println(sensorValue1);
Serial.println("/r");
delay(1000);
Serial.print("sensor value 2:");
Serial.println(sensorValue2);
Serial.println("/r");
lcd.setCursor(0,0);
lcd.print(sensorValue1);
lcd.setCursor(5,0);
lcd.print(sensorValue2);
if (sensorValue1>sensorValue2)
{
//lcd.setCursor(7,0);// x,y
//lcd.print("too dim!");
Serial.println("too dim!");
//tone(piezoPin, 2200, 1000);
//delay(1000);
//lcd.clear();
}
}
void ButtonTimer (void)
{
const int buttonPin = 2; // the number of the pushbutton pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH)
{
Neotimer mytimer = Neotimer(1800);//add 000 at end after test
//delay(1800000);
void setup()
{
mytimer.start();
}
void loop()
{
if(mytimer.done())
{
tone (piezoPin,2200,1000);
Serial.println("time's up!");
}
}
}
}
void setup()
{
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop()
{
UltrasoundSystem();
LightSystem();
ButtonTimer();
}
line 100 has the problem, but i dont know what problem!