I copy pasted a set of codes from a website and it keeps on showing me the /302 error. how do I fix it.
const int LMotor_pin1 = 9; // Pin 9 is named as Left Motor Pin 1
const int LMotor_pin2 = 10; // Pin 10 is named as Left Motor Pin 2
const int RMotor_pin1 = 11; // Pin 11 is named as Right Motor Pin 1
const int RMotor_pin2 = 12; // Pin 12 is named as Right Motor Pin 2
const int speaker = 13; // Pin 13 as named as speaker
#define NOTE_E5 659 //Assign a frequency value to each note
#define NOTE_G5 784
#define NOTE_FS5 740
#define NOTE_B5 988
#define NOTE_A5 880
#define NOTE_C4 262
#define NOTE_B4 494
//Create an array(sequence) of Notes and call it doremifa
int doremifa[] = {NOTE_E5, NOTE_G5, NOTE_FS5, NOTE_G5, NOTE_B5, NOTE_A5, NOTE_FS5, NOTE_G5, NOTE_E5, NOTE_G5, NOTE_FS5, NOTE_E5, NOTE_C4, NOTE_B4, NOTE_E5, NOTE_G5, NOTE_FS5, NOTE_G5, NOTE_B5, NOTE_A5, NOTE_FS5, NOTE_G5, NOTE_E5, NOTE_G5, NOTE_FS5, NOTE_E5, NOTE_C4, NOTE_E5};
int ledPins[] = {1,2,3,4,5,6}; // Create an array(sequence)of numbers and call it ledPins
void setup()
{
for (int count = 0; count <= 6; count++)
{
pinMode(ledPins[count], OUTPUT); // ledPins is replaced by the value 1 to 8 from the array
// and count loops it 8 times due to the "for" loop
//All 8 pins are now set as outputs.
}
pinMode(LMotor_pin1, OUTPUT); // Set Pins 9, 10, 11, 12 as OUTPUTS
pinMode(LMotor_pin2, OUTPUT);
pinMode(RMotor_pin1, OUTPUT);
pinMode(RMotor_pin2, OUTPUT);
pinMode(speaker, OUTPUT); // Set speaker - pin 13 as an output
}
void loop()
{
// this is the sequence of mini programs. These can be repeated or rearranged.
Rotate_Right ();
long_beat ();
Spin_Left ();
Spin_Right ();
medium_beat ();
zigzag_Forward ();
zigzag_Backward ();
Turn_Left ();
Turn_Right ();
fast_beat ();
Move_Forward ();
Move_Backward ();
Rotate_Left ();
}
void fast_beat ()
{
for (int i = 0; i < 6; i++) //starting a for loop to play each note from the array
{
digitalWrite(ledPins*, HIGH); // LED turns ON from 1 to 8 one after another*
_ tone(speaker, doremifa*); //Take the notes C5 to C6 from the array..._
_ delay(250); // ...for 250 msec*_
_ digitalWrite(ledPins*, LOW); // LED turns OFF from 1 to 8 one after another*
* delay(250); // ...for 250 msec*
* noTone(speaker); // Stop sound...*_
}
}
void fast_beat ()
{
* for (int i = 0; i < 6; i++) //starting a for loop to play each note from the array*
{
_ digitalWrite(ledPins*, HIGH); // LED turns ON from 1 to 8 one after another*
tone(speaker, doremifa*); //Take the notes C5 to C6 from the array...
delay(100); // ...for 100 msec*
digitalWrite(ledPins*, LOW); // LED turns OFF from 1 to 8 one after another*
* delay(100); // ...for 100 msec*
* noTone(speaker); // Stop sound...*_
*} *
}
void fast_beat ()
{
* for (int i = 0; i < 6; i++) //starting a for loop to play each note from the array*
{
_ digitalWrite(ledPins*, HIGH); // LED turns ON from 1 to 8 one after another*
tone(speaker, doremifa*); //Take the notes C5 to C6 from the array...
delay(500); // ...for 500 msec*
digitalWrite(ledPins*, LOW); // LED turns OFF from 1 to 8 one after another*
* delay(500); // ...for 500 msec*
* noTone(speaker); // Stop sound...*_
}
}
void Move_Forward ()
* {*
* digitalWrite(LMotor_pin1, HIGH); // Left Motor moves Forward
digitalWrite(LMotor_pin2, LOW); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(1, HIGH); // LED Pin 1 is turned ON*
* digitalWrite(5, HIGH);*_
* digitalWrite(RMotor_pin1, HIGH); // Right Motor moves Forward*
* digitalWrite(RMotor_pin2, LOW); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(3, HIGH); // LED Pin 2 is turned ON*_
* delay(1000);*
* digitalWrite(1, LOW); // LED Pin 1 is turned OFF*
* digitalWrite(2, LOW); // LED Pin 2 is turned OFF*
}
void Move_Backward ()
* {*
* digitalWrite(LMotor_pin1, LOW); // Left Motor moves Backwards
digitalWrite(LMotor_pin2, HIGH); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(3, HIGH); // LED Pin 3 is turned ON*_
* digitalWrite(RMotor_pin1, LOW); // Right Motor moves Backwards*
* digitalWrite(RMotor_pin2, HIGH); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(4, HIGH); // LED Pin 4 is turned ON *_
* delay(1000);*
* digitalWrite(3, LOW); // LED Pin 3 is turned OFF*
* digitalWrite(4, LOW); // LED Pin 4 is turned OFF*
}
void Turn_Left ()
* {*
* digitalWrite(LMotor_pin1, LOW); // Left Motor moves One way*
* digitalWrite(LMotor_pin2, HIGH); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(5, HIGH); // LED Pin 5 is turned ON*_
* digitalWrite(RMotor_pin1, HIGH); // Right Motor moves the Other way*
* digitalWrite(RMotor_pin2, LOW); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(6, HIGH); // LED Pin 6 is turned ON*_
* delay(400); // The value 400 has to be changed to get perfect Left Turn*
* digitalWrite(5, LOW); // LED Pin 5 is turned OFF*
* digitalWrite(6, LOW); // LED Pin 6 is turned OFF*
}
void Turn_Right ()
* {*
* digitalWrite(LMotor_pin1, HIGH); // Left Motor moves One way*
* digitalWrite(LMotor_pin2, LOW); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(7, HIGH); // LED Pin 7 is turned ON*_
* digitalWrite(RMotor_pin1, LOW); // Right Motor moves the Other way*
* digitalWrite(RMotor_pin2, HIGH); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(8, HIGH); // LED Pin 8 is turned ON*_
* delay(400); // The value 400 has to be changed to get perfect Right Turn*
* digitalWrite(7, LOW); // LED Pin 7 is turned OFF*
* digitalWrite(8, LOW); // LED Pin 8 is turned OFF*
}
* void Rotate_Left ()
_ {_
digitalWrite(LMotor_pin1, HIGH); // Left Motor moves One way*
* digitalWrite(LMotor_pin2, LOW); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(5, HIGH); // LED Pin 5 is turned ON*_
* digitalWrite(RMotor_pin1, HIGH); // Right Motor moves the Other way*
* digitalWrite(RMotor_pin2, LOW); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(6, HIGH); // LED Pin 6 is turned ON*_
* delay(1500); // The value 1500 has to be changed to get desired Left Rotation*
* digitalWrite(5, LOW); // LED Pin 5 is turned OFF*
* digitalWrite(6, LOW); // LED Pin 6 is turned OFF*
}
void Rotate_Right ()
* {*
* digitalWrite(LMotor_pin1, LOW); // Left Motor moves One way*
* digitalWrite(LMotor_pin2, HIGH); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(7, HIGH); // LED Pin 7 is turned ON*_
* digitalWrite(RMotor_pin1, LOW); // Right Motor moves the Other way*
* digitalWrite(RMotor_pin2, HIGH); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(8, HIGH); // LED Pin 8 is turned ON*_
* delay(1500); // The value 1500 has to be changed to get desired Right Rotation*
* digitalWrite(7, LOW); // LED Pin 7 is turned OFF*
* digitalWrite(8, LOW); // LED Pin 8 is turned OFF*
}
void Spin_Left ()
* {*
* digitalWrite(LMotor_pin1, LOW); // Left Motor moves One way*
* digitalWrite(LMotor_pin2, HIGH); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(5, HIGH); // LED Pin 5 is turned ON*_
* digitalWrite(RMotor_pin1, LOW); // Right Motor does not move*
* digitalWrite(RMotor_pin2, LOW); // Change the “HIGH” or “LOW” to suit your robot.
_ digitalWrite(6, HIGH); // LED Pin 6 is turned ON*_
* delay(2000); // The value 2000 has to be changed to get the desired Left Rotation*
* digitalWrite(5, LOW); // LED Pin 5 is turned OFF*
* digitalWrite(6, LOW); // LED Pin 6 is turned OFF*
}
}