problem with code

Hi gys please help me :slight_smile:

void softInterr()
{
// Reading from first ultrasonic sensor
digitalWrite(triggerpin1, LOW);
delayMicroseconds(2);
digitalWrite(triggerpin1, HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin1, LOW);
time = pulseIn(echopin1, HIGH);
S1= time0.034/2;
// Reading from second ultrasonic sensor
digitalWrite(triggerpin2, LOW);
delayMicroseconds(2);
digitalWrite(triggerpin2, HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin2, LOW);
time = pulseIn(echopin2, HIGH);
S2= time
0.034/2;
// Reading from third ultrasonic sensor
digitalWrite(triggerpin3, LOW);
delayMicroseconds(2);
digitalWrite(triggerpin3, HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin3, LOW);
time = pulseIn(echopin3, HIGH);
S3= time0.034/2;
// Reading from fourth ultrasonic sensor
digitalWrite(triggerpin4, LOW);
delayMicroseconds(2);
digitalWrite(triggerpin4, HIGH);
delayMicroseconds(10);
digitalWrite(triggerpin4, LOW);
time = pulseIn(echopin4, HIGH);
S4= time
0.034/2;
// Print distance values on serial monitor for debugging
Serial.print("S1: β€œ);
Serial.print(S1);
Serial.print(” S2: β€œ);
Serial.print(S2);
Serial.print(” S3: β€œ);
Serial.print(S3);
Serial.print(” S4: ");
Serial.println(S4);
}

void signal1Function()
{
Serial.println(β€œ1”);
low();
// Make RED LED LOW and make Green HIGH for 5 seconds
digitalWrite(signal1[0], LOW);
digitalWrite(signal1[2], HIGH);
delay(redDelay);
// if there are vehicels at other signals
if(S2<t || S3<t || S4<t)
{
// Make Green LED LOW and make yellow LED HIGH for 2 seconds
digitalWrite(signal1[2], LOW);
digitalWrite(signal1[1], HIGH);
delay(yellowDelay);
}
}
void signal2Function()
{
Serial.println(β€œ2”);
low();
digitalWrite(signal2[0], LOW);
digitalWrite(signal2[2], HIGH);
delay(redDelay);

if(S1<t || S3<t || S4<t)
{
digitalWrite(signal2[2], LOW);
digitalWrite(signal2[1], HIGH);
delay(yellowDelay);
}
}
void signal3Function()
{
Serial.println(β€œ3”);
low();
digitalWrite(signal3[0], LOW);
digitalWrite(signal3[2], HIGH);
delay(redDelay);
if(S1<t || S2<t || S4<t)
{
digitalWrite(signal3[2], LOW);
digitalWrite(signal3[1], HIGH);
delay(yellowDelay);
}
}
void signal4Function(){
Serial.println(β€œ4”);
low();
digitalWrite(signal4[0], LOW);
digitalWrite(signal4[2], HIGH);
delay(redDelay);
if(S1<t || S2<t || S3<t)
{
digitalWrite(signal4[2], LOW);
digitalWrite(signal4[1], HIGH);
delay(yellowDelay);
}
}
// Function to make all LED’s LOW except RED one’s.

void low(){
for(int i=1; i<3; i++)
{
digitalWrite(signal1*, LOW);*
_ digitalWrite(signal2*, LOW);_
_ digitalWrite(signal3, LOW);
digitalWrite(signal4, LOW);
}
for(int i=0; i<1; i++)
{
digitalWrite(signal1, HIGH);
digitalWrite(signal2, HIGH);
digitalWrite(signal3, HIGH);
digitalWrite(signal4, HIGH);
}
}
Error:
C:\Users\HP\Desktop\LEVEL-10\Senoir_Project_2\Code\STCSProject\STCSProject.ino: In function β€˜void softInterr()’:
STCSProject:58:1: error: a function-definition is not allowed here before β€˜{’ token
{
^
STCSProject:80:14: error: a function-definition is not allowed here before β€˜{’ token
void setup() {
^
STCSProject:104:1: error: a function-definition is not allowed here before β€˜{’ token
{
^
STCSProject:128:1: error: a function-definition is not allowed here before β€˜{’ token
{
^
STCSProject:175:1: error: a function-definition is not allowed here before β€˜{’ token
{
^
STCSProject:192:1: error: a function-definition is not allowed here before β€˜{’ token
{
^
STCSProject:207:1: error: a function-definition is not allowed here before β€˜{’ token
{
^
STCSProject:220:23: error: a function-definition is not allowed here before β€˜{’ token
void signal4Function(){
^
STCSProject:235:11: error: a function-definition is not allowed here before β€˜{’ token
void low(){
^*

Using library TimerOne in folder: C:\Users\HP\Documents\Arduino\libraries\TimerOne (legacy)
exit status 1
a function-definition is not allowed here before β€˜{’ token_

You obviously didn’t read the old thread you chose to post in. If you had you would have posted the COMPLETE program and error messages, both in </> code tags.

Steve

@nadasalem_mk

TOPIC SPLIT
DO NOT HIJACK / NECRO POST !

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

You obviously have not posted the complete sketch. The error message you are seeing is typically caused by trying to define a function within another function, and often results from mismatched brackets or parenthesis in code prior to the line that generates the error message. If you are using the Arduion IDE, use Tools > Auto Format to auto format the code and the problem will usually be fairly obvious.