software error

Arduino specifieke Software
Berichten: 14
Geregistreerd: 25 Nov 2015, 13:31

software error

Berichtdoor swift » 17 Sep 2022, 16:45

/*
State change detection (edge detection)


This is based on example code is in the public domain.

http://arduino.cc/en/Tutorial/ButtonStateChange

Servo

https://www.arduino.cc/en/Reference/Servo


*/
#include <Servo.h>


// this constant won't change:
const int buttonPin = A0; // the pin that 1st the digital pushbutton is attached to
const int buttonPin1 = A1; // the pin that 2nd the digital pushbutton is attached to
const int buttonPin2 = A2; // the pin that 3th the servo pushbutton is attached to
const int buttonPin3 = A3; // the pin that 5th the servo pushbutton is attached to
const int buttonPin4 = A4; // the pin that 6th the servo pushbutton is attached to
const int buttonPin5 = A5; // the pin that 9th the servo pushbutton is attached to
const int buttonPin6 = 2; // the pin that 10th the servo pushbutton is attached to
const int buttonPin7 = 4; // the pin that 11th the servo pushbutton is attached to

Servo myservo3;
Servo myservo5;
Servo myservo6;
Servo myservo9;
Servo myservo10;
Servo myservo11;

const int ledPin1 = 12; // the pin that the LED is attached to
const int ledPin2 = 13; // the pin that the LED is attached to

// Variables will change:

// 1st input/output
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button

// 2nd input/output
int buttonPushCounter1 = 0; // counter for the number of button presses
int buttonState1 = 0; // current state of the button
int lastButtonState1 = 0; // previous state of the button

// 3th input/output
int buttonPushCounter2 = 0; // counter for the number of button presses
int buttonState2 = 0; // current state of the button
int lastButtonState2 = 0; // previous state of the button

// 4th input/output
int buttonPushCounter3 = 0; // counter for the number of button presses
int buttonState3 = 0; // current state of the button
int lastButtonState3 = 0; // previous state of the button

// 5th input/output
int buttonPushCounter4 = 0; // counter for the number of button presses
int buttonState4 = 0; // current state of the button
int lastButtonState4 = 0; // previous state of the button

// 6th input/output
int buttonPushCounter5 = 0; // counter for the number of button presses
int buttonState5 = 0; // current state of the button
int lastButtonState5 = 0; // previous state of the button

// 7th input/output
int buttonPushCounter6 = 0; // counter for the number of button presses
int buttonState6 = 0; // current state of the button
int lastButtonState6 = 0; // previous state of the button

// 8th input/output
int buttonPushCounter7 = 0; // counter for the number of button presses
int buttonState7 = 0; // current state of the button
int lastButtonState7 = 0; // previous state of the button




void setup() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
pinMode(buttonPin6, INPUT);
pinMode(buttonPin7, INPUT);


// initialize the LED as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);

// initelize the and attach the servos
myservo3.attach(3);
myservo5.attach(5);
myservo6.attach(6);
myservo9.attach(9);
myservo10.attach(10);
myservo11.attach(11);

// initialize serial communication:
Serial.begin(9600);
}


void loop() {


//-------------------------------------------------

// read the pushbutton input pin1 1st servo (myservo3) :
buttonState2 = digitalRead(buttonPin2);

// compare the buttonState to its previous state
if (buttonState2 != lastButtonState2) {
// if the state has changed, increment the counter
if (buttonState2 == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter2++;
Serial.println("high servo 3");
Serial.print("number of button2 pushes: ");
Serial.println(buttonPushCounter2);
}
else {
// if the current state is LOW then the button
// wend from on to off:
Serial.println("low servo 3");
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState2 = buttonState2;


// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter2 % 2 == 0) {
myservo3.write (50);
} else {
myservo3.write (150);
}

//-------------------------------------------------


// read the pushbutton input pin 2nd servo (myservo5) :
buttonState3 = digitalRead(buttonPin3);

// compare the buttonState to its previous state
if (buttonState3 != lastButtonState3) {
// if the state has changed, increment the counter
if (buttonState3 == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter3++;
Serial.println("servo 5 high");
Serial.print("number of button3 pushes: ");
Serial.println(buttonPushCounter3);
}
else {
// if the current state is LOW then the button
// wend from on to off:
Serial.println("servo 5 low");
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState3 = buttonState3;


// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter3 % 2 == 0) {
myservo5.write (50);
} else {
myservo5.write (150);
}

//-------------------------------------------------


// read the pushbutton input pin 3th servo (myservo6) :
buttonState4 = digitalRead(buttonPin4);

// compare the buttonState to its previous state
if (buttonState4 != lastButtonState4) {
// if the state has changed, increment the counter
if (buttonState4 == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter4++;
Serial.println("servo 4 high");
Serial.print("number of button4 pushes: ");
Serial.println(buttonPushCounter4);
}
else {
// if the current state is LOW then the button
// wend from on to off:
Serial.println("servo 6 low");
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState4 = buttonState4;


// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter4 % 2 == 0) {
myservo6.write (50);
} else {
myservo6.write (150);
}


//-------------------------------------------------


// read the pushbutton input pin 4th servo (myservo9) :
buttonState5 = digitalRead(buttonPin5);

// compare the buttonState to its previous state
if (buttonState5 != lastButtonState5) {
// if the state has changed, increment the counter
if (buttonState5 == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter5++;
Serial.println("servo 9 high");
Serial.print("number of button5 pushes: ");
Serial.println(buttonPushCounter5);
}
else {
// if the current state is LOW then the button
// wend from on to off:
Serial.println("servo 9 low");
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState5 = buttonState5;


// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter5 % 2 == 0) {
myservo9.write (50);
} else {
myservo9.write (150);
}


//-------------------------------------------------


// read the pushbutton input pin 5th servo (myservo10) :
buttonState6 = digitalRead(buttonPin6);

// compare the buttonState to its previous state
if (buttonState6 != lastButtonState6) {
// if the state has changed, increment the counter
if (buttonState6 == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter6++;
Serial.println("servo 10 high");
Serial.print("number of button6 pushes: ");
Serial.println(buttonPushCounter6);
}
else {
// if the current state is LOW then the button
// wend from on to off:
Serial.println("servo 10 low");
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState6 = buttonState6;


// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter6 % 2 == 0) {
myservo10.write (50);
} else {
myservo10.write (150);
}


//-------------------------------------------------


// read the pushbutton input pin 6th servo (myservo11) :
buttonState7 = digitalRead(buttonPin7);

// compare the buttonState to its previous state
if (buttonState7 != lastButtonState7) {
// if the state has changed, increment the counter
if (buttonState7 == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter7++;
Serial.println("servo 11 high");
Serial.print("number of button7 pushes: ");
Serial.println(buttonPushCounter7);
}
else {
// if the current state is LOW then the button
// wend from on to off:
Serial.println("servo 11 low");
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState7 = buttonState7;


// turns on the LED every four button pushes by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter7 % 2 == 0) {
myservo11.write (50);
} else {
myservo11.write (150);
}
delay (200);
}

Als ik deze sketch wil uploaden in 'n Arduino Nano krijg ik 'n error , wie kan mij helpen

Advertisement

Berichten: 128
Geregistreerd: 26 Aug 2015, 11:57

Re: software error

Berichtdoor Frits1956 » 17 Sep 2022, 17:25

het is makkelijker te lezen als je de code tussen "[code][/code]" (zonder aanhalingstekens) zet.

Hier gaat het compileren goed maar ik heb geen nano dus kan niet uploaden. Wat is je foutmelding?

Berichten: 14
Geregistreerd: 25 Nov 2015, 13:31

Re: software error

Berichtdoor swift » 18 Sep 2022, 13:28

krijg allen dit,

Er trad een error op gedurende laden van de schets

Berichten: 14
Geregistreerd: 25 Nov 2015, 13:31

Re: software error

Berichtdoor swift » 19 Sep 2022, 09:07

deze sketch heeft een hele tijd gewerkt, maar na vervangen van Arduino Nano niet meer ( die was defect )

Berichten: 128
Geregistreerd: 26 Aug 2015, 11:57

Re: software error

Berichtdoor Frits1956 » 19 Sep 2022, 10:41

swift schreef:krijg allen dit,

Er trad een error op gedurende laden van de schets

Hoe weet je dan dat er een error is als je geen melding krijgt?

Berichten: 14
Geregistreerd: 25 Nov 2015, 13:31

Re: software error

Berichtdoor swift » 19 Sep 2022, 11:39

"er trad een error op gedurende laden van de schets" deze vermelding kreeg ik na het laden onderin beeld ( oranje balk)

Berichten: 128
Geregistreerd: 26 Aug 2015, 11:57

Re: software error

Berichtdoor Frits1956 » 19 Sep 2022, 19:15

swift schreef:"er trad een error op gedurende laden van de schets" deze vermelding kreeg ik na het laden onderin beeld ( oranje balk)

Dat lijkt mij een error bij het laden van de schets en geen compiler error. Ik heb dat ook een heel enkele keer, dan sluit ik de IDE, start die opnieuw op en probeer het nog een keer. Kan je alleen dat advies geven. suc7

Berichten: 3867
Geregistreerd: 16 Okt 2013, 14:31
Woonplaats: s hertogenbosch

Re: software error

Berichtdoor shooter » 20 Sep 2022, 06:13

kijk of je de goede board gebruikt dus met old booter en naar de poort kijken of deze goed staat
paul deelen
shooter@home.nl

Berichten: 14
Geregistreerd: 25 Nov 2015, 13:31

Re: software error

Berichtdoor swift » 20 Sep 2022, 09:35

Frits 1956 ; Heb al verschillende keren opnieuw opgestart en met 'n andere nieuwe Nano en ook op 'n andere laptop, zelfde melding

shooter ; Heb volgens mij het goede board gebruikt met old booter en verschillende poorten gebruikt ; com 5 ; com 6 ; com 7 zelfde probleem

Berichten: 14
Geregistreerd: 25 Nov 2015, 13:31

Re: software error

Berichtdoor swift » 20 Sep 2022, 12:38

Heb daarnet ook arduino ide opnieuw geinstaleerd 2.0.0

Terug naar Arduino software

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 7 gasten