I'm new to the whole coding thing and wanted to test to see if I could make an RC car. I just don't know what I'm doing and get a lot of error messages with no idea on how to fix them. There's supposed to be about 4 moving parts, 3 servos, 1 motor, using a bluetooth module to control from my phone. The code is currently
char inputByte = 'z';
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
while (Serial.available() > 0) {
inputByte = Serial.read();
if (inputByte == 'Z')
{ digitalWrite(13, HIGH);
}
else (inputByte == 'z')
{
digitalWrite(13, LOW);
}
}
Servo headlights;
Servo left;
Servo right;
void loop()
char inputByte = 'z';
int pos = 0; // headlights pos
void setup() {
headlights.attach(9);
}
Serial.begin(9600);
pinMode(9, OUTPUT);
void loop() {
while (Serial.available() > 0) {
inputByte = Serial.read();
Serial.println(c);
if (inputByte == 'Y') {
void loop() {
for (pos = 0; pos <= 90; pos += 1) {
// in steps of 1 degree
headlights.write(pos);
delay(150);
}
else if (inputByte == 'y') {
for (pos = 90; pos <= 0; pos -= 1) {
// in steps of 1 degree
headlights.write(pos);
delay(1000); // headlight control
}
void setup() {
left.attach(10); // Left wheel
}
void loop() {
for (pos = 0; pos <= 300; pos -= 1) {
// in steps of 1 degree
left.write(pos);
delay(1000);
}
for (pos = 300; pos >= 0; pos += 1) {
/
left.write(pos);
delay(10);
}
void setup() {
right.attach(11);
}
void loop() {
for (pos = 0; pos <= 60; pos += 1) { //
// in steps of 1 degree
right.write(pos); //
delay(1000); //
}
for (pos = 60; pos >= 0; pos -= 1) { //
right.write(pos); //
delay(15); //
}
}
and I haven't been able to understand what to fix so far
error messages are
Arduino: 1.8.20 Hourly Build 2021/12/20 07:33 (Windows 10), Board: "Arduino Uno"
test_-_FD:11:6: error: 'else' without a previous 'if'
;else (inputByte == 'z')
^~~~
test_-_FD:12:5: error: expected ';' before '{' token
{
^
test_-_FD:16:3: error: 'Servo' was not declared in this scope
Servo headlights;
^~~~~
C:\Users\myste\Documents\Arduino\test_-FD\test-_FD.ino:16:3: note: suggested alternative: 'Serial'
Servo headlights;
^~~~~
Serial
test_-_FD:17:9: error: expected ';' before 'left'
Servo left;
^~~~
test_-_FD:18:9: error: expected ';' before 'right'
Servo right;
^~~~~
test_-_FD:20:3: error: expected initializer before 'char'
char inputByte = 'z';
^~~~
test_-_FD:25:16: error: a function-definition is not allowed here before '{' token
void setup() {
^
test_-_FD:31:15: error: a function-definition is not allowed here before '{' token
void loop() {
^
test_-_FD:77:15: error: expected '}' at end of input
}
^
exit status 1
'else' without a previous 'if'
Any tips??