ive spent 2 days trying edit errors out of code. says i have wrong {}.
ive moved { after void commands, , more errors.
im looking motor sweep.
a heartbeat type led, , flash relay on, , off using transistor, resistor, , diode on pin 11.
if can advice small program.
error codes;
sketch_apr05a.ino:91:1: error: function-definition not allowed here before '{' token
sketch_apr05a.ino:101:1: error: expected '}' @ end of input
sketch_apr05a.ino:101:1: error: expected '}' @ end of input
error compiling.
code.
// sweep
// barragan <http://barraganstudio.com>
// example code in public domain.
#include <servo.h>
servo myservo; // create servo object control servo
// maximum of 8 servo objects can created
int pos = 0; // variable store servo position
void setup()
{
myservo.attach(9); // attaches servo on pin 9 servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes 0 degrees 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo go position in variable 'pos'
delay(15); // waits 15ms servo reach position
}
for(pos = 180; pos>=1; pos-=1) // goes 180 degrees 0 degrees
{
myservo.write(pos); // tell servo go position in variable 'pos'
delay(15); // waits 15ms servo reach position
}
/*
blink
turns on led on 1 second, off 1 second, repeatedly.
example code in public domain.
*/
// pin 13 has led connected on arduino boards.
// give name:
int led = 13;
// setup routine runs once when press reset:
void loop () {
// initialize digital pin output.
pinmode(led, output);
// loop routine runs on , on again forever:
digitalwrite(led, high); // turn led on (high voltage level)
delay(400); // wait 400ms
digitalwrite(led, low); // turn led off making voltage low
delay(100); // wait 100ms
digitalwrite(led, high); // turn led on (high voltage level)
delay(500); // wait 500ms
digitalwrite(led, low); // turn led off making voltage low
delay(30000); // wait 30 second
}
/*
blink
turns on led on 1 second, off 1 second, repeatedly.
example code in public domain.
*/
// pin 11 has led connected on arduino boards.
// give name:
int led = 11;
{
// initialize digital pin output.
pinmode(led, output);
// loop routine runs on , on again forever:
void loop ()
{
digitalwrite(led, high); // turn led on (high voltage level)
delay(1000); // wait second
digitalwrite(led, low); // turn led off making voltage low
delay(1000); // wait second
}
ive moved { after void commands, , more errors.
im looking motor sweep.
a heartbeat type led, , flash relay on, , off using transistor, resistor, , diode on pin 11.
if can advice small program.
error codes;
sketch_apr05a.ino:91:1: error: function-definition not allowed here before '{' token
sketch_apr05a.ino:101:1: error: expected '}' @ end of input
sketch_apr05a.ino:101:1: error: expected '}' @ end of input
error compiling.
code.
// sweep
// barragan <http://barraganstudio.com>
// example code in public domain.
#include <servo.h>
servo myservo; // create servo object control servo
// maximum of 8 servo objects can created
int pos = 0; // variable store servo position
void setup()
{
myservo.attach(9); // attaches servo on pin 9 servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes 0 degrees 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo go position in variable 'pos'
delay(15); // waits 15ms servo reach position
}
for(pos = 180; pos>=1; pos-=1) // goes 180 degrees 0 degrees
{
myservo.write(pos); // tell servo go position in variable 'pos'
delay(15); // waits 15ms servo reach position
}
/*
blink
turns on led on 1 second, off 1 second, repeatedly.
example code in public domain.
*/
// pin 13 has led connected on arduino boards.
// give name:
int led = 13;
// setup routine runs once when press reset:
void loop () {
// initialize digital pin output.
pinmode(led, output);
// loop routine runs on , on again forever:
digitalwrite(led, high); // turn led on (high voltage level)
delay(400); // wait 400ms
digitalwrite(led, low); // turn led off making voltage low
delay(100); // wait 100ms
digitalwrite(led, high); // turn led on (high voltage level)
delay(500); // wait 500ms
digitalwrite(led, low); // turn led off making voltage low
delay(30000); // wait 30 second
}
/*
blink
turns on led on 1 second, off 1 second, repeatedly.
example code in public domain.
*/
// pin 11 has led connected on arduino boards.
// give name:
int led = 11;
{
// initialize digital pin output.
pinmode(led, output);
// loop routine runs on , on again forever:
void loop ()
{
digitalwrite(led, high); // turn led on (high voltage level)
delay(1000); // wait second
digitalwrite(led, low); // turn led off making voltage low
delay(1000); // wait second
}
first of all... have 3 loop() functions ! not possible....
then ... not use delay() blink leds - use blinkwithoutdelay example see how can done.
and... put code in code tags before posting on forum.
try :
then ... not use delay() blink leds - use blinkwithoutdelay example see how can done.
and... put code in code tags before posting on forum.
try :
code: [select]
#include <servo.h>
servo myservo; // create servo object control servo
// maximum of 8 servo objects can created
int led = 13;
int pos = 0; // variable store servo position
void setup()
{
pinmode(led, output);
myservo.attach(9); // attaches servo on pin 9 servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes 0 degrees 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo go position in variable 'pos'
delay(15); // waits 15ms servo reach position
}
for(pos = 180; pos>=1; pos-=1) // goes 180 degrees 0 degrees
{
myservo.write(pos); // tell servo go position in variable 'pos'
delay(15); // waits 15ms servo reach position
}
}
Arduino Forum > Using Arduino > Programming Questions > Errors compiling need advice with editing.
arduino
Comments
Post a Comment