Arduino Starter Kit example Project 8 - Digital Hourglass
11 berichten
• Pagina 1 van 2 • 1, 2
Arduino Starter Kit example Project 8 - Digital Hourglass
Beste,
we hebben in een les "Arduino Starter Kit example Project 8 - Digital Hourglass" (Arduino 1.6.5) getest met drie verschillende Arduino Uno's.
Als we het breadboard kantelen wanneer alle LED's branden begint de cyclus opnieuw op voorwaarde dat we dat relatief kort na het einde van een cyclus doen ; als we een kwartiertje of wat langer wachten gebeurd er niets : alle LED's blijven branden.
Heeft er iemand hier een verklaring voor?
Beste dank.
we hebben in een les "Arduino Starter Kit example Project 8 - Digital Hourglass" (Arduino 1.6.5) getest met drie verschillende Arduino Uno's.
Als we het breadboard kantelen wanneer alle LED's branden begint de cyclus opnieuw op voorwaarde dat we dat relatief kort na het einde van een cyclus doen ; als we een kwartiertje of wat langer wachten gebeurd er niets : alle LED's blijven branden.
Heeft er iemand hier een verklaring voor?
Beste dank.
Advertisement
Re: Arduino Starter Kit example Project 8 - Digital Hourgl
er loopt teveel stroom, dus de voeding stopt ermee, weerstanden 150% maken helpt.
ofwel 330 ohm
ofwel 330 ohm
paul deelen
shooter@home.nl
shooter@home.nl
Re: Arduino Starter Kit example Project 8 - Digital Hourgl
Zouden de LED's niet uitgaan zonder voeding?
Re: Arduino Starter Kit example Project 8 - Digital Hourgl
sorry verkeerde antwoord.
laat de software maar eens zien, wellicht doen jullie iets fout met een timer of zo,
laat de software maar eens zien, wellicht doen jullie iets fout met een timer of zo,
paul deelen
shooter@home.nl
shooter@home.nl
Re: Arduino Starter Kit example Project 8 - Digital Hourgl
De code is gewoon "ge-upload" vanuit de integrated development environment van Arduino:
cpp code
cpp code
/*
Arduino Starter Kit example
Project 8 - Digital Hourglass
This sketch is written to accompany Project 8 in the
Arduino Starter Kit
Parts required:
10 kilohm resistor
six 220 ohm resistors
six LEDs
tilt switch
Created 13 September 2012
by Scott Fitzgerald
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
// named constant for the switch pin
const int switchPin = 8;
unsigned long previousTime = 0; // store the last time an LED was updated
int switchState = 0; // the current switch state
int prevSwitchState = 0; // the previous switch state
int led = 2; // a variable to refer to the LEDs
// 600000 = 10 minutes in milliseconds
long interval = 600000; // interval at which to light the next LED
void setup() {
// set the LED pins as outputs
for (int x = 2; x < 8; x++) {
pinMode(x, OUTPUT);
}
// set the tilt switch pin as input
pinMode(switchPin, INPUT);
}
void loop() {
// store the time since the Arduino started running in a variable
unsigned long currentTime = millis();
// compare the current time to the previous time an LED turned on
// if it is greater than your interval, run the if statement
if (currentTime - previousTime > interval) {
// save the current time as the last time you changed an LED
previousTime = currentTime;
// Turn the LED on
digitalWrite(led, HIGH);
// increment the led variable
// in 10 minutes the next LED will light up
led++;
if (led == 7) {
// the hour is up
}
}
// read the switch value
switchState = digitalRead(switchPin);
// if the switch has changed
if (switchState != prevSwitchState) {
// turn all the LEDs low
for (int x = 2; x < 8; x++) {
digitalWrite(x, LOW);
}
// reset the LED variable to the first one
led = 2;
//reset the timer
previousTime = currentTime;
}
// set the previous switch state to the current state
prevSwitchState = switchState;
}
Re: Arduino Starter Kit example Project 8 - Digital Hourgl
na 6 keer is de led 7.
dan wordt digitalWrite(8,HIGH); maar dat is wel je switchpin, en dus gebeurt er niks meer.
als alle ledjes branden, dan moet je stoppen dus if (led >= 7) {led=2} is geen probleem want die staat toch al aan.
probeer maar eens door de switch op 11 te zetten.
en jullie hebben gelijk het is pas na 10 minuten = 600000 millis.
zet de tijd op 6000 dan gaat het allemaal wat sneller.
dan wordt digitalWrite(8,HIGH); maar dat is wel je switchpin, en dus gebeurt er niks meer.
als alle ledjes branden, dan moet je stoppen dus if (led >= 7) {led=2} is geen probleem want die staat toch al aan.
probeer maar eens door de switch op 11 te zetten.
en jullie hebben gelijk het is pas na 10 minuten = 600000 millis.
zet de tijd op 6000 dan gaat het allemaal wat sneller.
paul deelen
shooter@home.nl
shooter@home.nl
Re: Arduino Starter Kit example Project 8 - Digital Hourgl
I ben een absolute beginner in Arduino en ik heb " for (int x = 2; x < 8; x++) " nog niet geprobeerd maar denk toch dat die verklaring niet klopt :
1) ook als ik het interval verkort naar 10 seconden is het pas na meer dan 8 minuten dat de LED's niet uitgaan door het bord te bewegen
2) pin 2 tot en met 7 zijn OUTPUI , pin 8 is INPUT.
1) ook als ik het interval verkort naar 10 seconden is het pas na meer dan 8 minuten dat de LED's niet uitgaan door het bord te bewegen
2) pin 2 tot en met 7 zijn OUTPUI , pin 8 is INPUT.
Re: Arduino Starter Kit example Project 8 - Digital Hourgl
pak een stukje papier en schrijf dan de cycli eens op.
de led gaat gewoon door want bij if led==7 staat niks, dus gaat gewoon door.
dat komt omdat {{{{{}}}}} niet kloppen.
en dus led kan 8 worden en dan staat er digitalWrite (8,HIGH) en dat is jouw input, en dat klopt natuurlijk niet.
wil je de code aub eerst even autoformat doen (Ctrl T) dan kopieren en hier tussen de code2=cpp zetten dat leest makkeleijker en ik hoef de ide niet te starten.
de led gaat gewoon door want bij if led==7 staat niks, dus gaat gewoon door.
dat komt omdat {{{{{}}}}} niet kloppen.
en dus led kan 8 worden en dan staat er digitalWrite (8,HIGH) en dat is jouw input, en dat klopt natuurlijk niet.
wil je de code aub eerst even autoformat doen (Ctrl T) dan kopieren en hier tussen de code2=cpp zetten dat leest makkeleijker en ik hoef de ide niet te starten.
paul deelen
shooter@home.nl
shooter@home.nl
- nicoverduin
- Berichten: 5043
- Geregistreerd: 13 Mei 2013, 20:57
- Woonplaats: Heemskerk
Re: Arduino Starter Kit example Project 8 - Digital Hourgl
shooter schreef:
wil je de code aub eerst even autoformat doen (Ctrl T) dan kopieren en hier tussen de code2=cpp zetten dat leest makkeleijker en ik hoef de ide niet te starten.
Je moest eens weten hoe vaak ik die code 2 erbij zit te zetten Maar ik ben het helemaal met je eens met dat if statement
Re: Arduino Starter Kit example Project 8 - Digital Hourgl
Beste,
ik heb uw suggestie geprobeerd en " if (led > 7) { led = 2 ; } " ingevoerd ; niet (led >= 7) : dan gaat laatste LED niet branden.
Dan gaat het prima.
Ik begrijp wel nog niet waarom het herstarten,door het board te bewegen na afloop van een cyclus, wel ging gedurende een relatief korte tijd na afloop en waarom het wat later niet meer ging.
Ik heb wel het interval op 1000 milliseconden gezet en ik heb uit het forum.arduino.cc ( Topic: Digital Hourglass will not execute at 600 000 ms (10mins) ) de code voor de seriële monitor overgenomen en in die monitor zie ik inderdaad dat zonder de aanpassing " if (led > 7) { led = 2 ; } " er telkens om de seconde een LED lijkt bij te komen; dit loopt door tot de teller op 54 staat en lijkt de teller op hol te slaan en loopt zeer snel tussen 46 en 54.
Wat U bedoelt met "tussen de code2=cpp zetten" begrijp ik niet maar dit is nu mijn code :
/*
Arduino Starter Kit example
Project 8 - Digital Hourglass
This sketch is written to accompany Project 8 in the
Arduino Starter Kit
Parts required:
10 kilohm resistor
six 220 ohm resistors
six LEDs
tilt switch
Created 13 September 2012
by Scott Fitzgerald
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
// named constant for the switch pin
const int switchPin = 8;
unsigned long previousTime = 0; // store the last time an LED was updated
int switchState = 0; // the current switch state
int prevSwitchState = 0; // the previous switch state
int led = 2; // a variable to refer to the LEDs
// 600000 = 10 minutes in milliseconds
long interval = 1000; // interval at which to light the next LED
void setup() {
Serial.begin(9600); // niet in handleiding
// set the LED pins as outputs
for (int x = 2; x < 8; x++) {
pinMode(x, OUTPUT);
}
// set the tilt switch pin as input
pinMode(switchPin, INPUT);
}
void loop() {
// store the time since the Arduino started running in a variable
unsigned long currentTime = millis();
// compare the current time to the previous time an LED turned on
// if it is greater than your interval, run the if statement
if (currentTime - previousTime > interval) {
// save the current time as the last time you changed an LED
previousTime = currentTime;
Serial.print ( "LED: "); // staat niet in handleiding
Serial.println (led); // staat niet in handleiding
// Turn the LED on
digitalWrite(led, HIGH);
// increment the led variable
// in 10 minutes the next LED will light up
led++;
if (led > 7) {
led = 2 ; // staat niet in de handleiding
// the hour is up
}
}
// read the switch value
switchState = digitalRead(switchPin);
// if the switch has changed
if (switchState != prevSwitchState) {
// turn all the LEDs low
for (int x = 2; x < 8; x++) {
digitalWrite(x, LOW);
}
// reset the LED variable to the first one
led = 2;
//reset the timer
previousTime = currentTime;
}
// set the previous switch state to the current state
prevSwitchState = switchState;
}
Misschien is het nuttig ook forum.arduino.cc hierover iets te laten weten.
Beste dank
ik heb uw suggestie geprobeerd en " if (led > 7) { led = 2 ; } " ingevoerd ; niet (led >= 7) : dan gaat laatste LED niet branden.
Dan gaat het prima.
Ik begrijp wel nog niet waarom het herstarten,door het board te bewegen na afloop van een cyclus, wel ging gedurende een relatief korte tijd na afloop en waarom het wat later niet meer ging.
Ik heb wel het interval op 1000 milliseconden gezet en ik heb uit het forum.arduino.cc ( Topic: Digital Hourglass will not execute at 600 000 ms (10mins) ) de code voor de seriële monitor overgenomen en in die monitor zie ik inderdaad dat zonder de aanpassing " if (led > 7) { led = 2 ; } " er telkens om de seconde een LED lijkt bij te komen; dit loopt door tot de teller op 54 staat en lijkt de teller op hol te slaan en loopt zeer snel tussen 46 en 54.
Wat U bedoelt met "tussen de code2=cpp zetten" begrijp ik niet maar dit is nu mijn code :
/*
Arduino Starter Kit example
Project 8 - Digital Hourglass
This sketch is written to accompany Project 8 in the
Arduino Starter Kit
Parts required:
10 kilohm resistor
six 220 ohm resistors
six LEDs
tilt switch
Created 13 September 2012
by Scott Fitzgerald
http://www.arduino.cc/starterKit
This example code is part of the public domain
*/
// named constant for the switch pin
const int switchPin = 8;
unsigned long previousTime = 0; // store the last time an LED was updated
int switchState = 0; // the current switch state
int prevSwitchState = 0; // the previous switch state
int led = 2; // a variable to refer to the LEDs
// 600000 = 10 minutes in milliseconds
long interval = 1000; // interval at which to light the next LED
void setup() {
Serial.begin(9600); // niet in handleiding
// set the LED pins as outputs
for (int x = 2; x < 8; x++) {
pinMode(x, OUTPUT);
}
// set the tilt switch pin as input
pinMode(switchPin, INPUT);
}
void loop() {
// store the time since the Arduino started running in a variable
unsigned long currentTime = millis();
// compare the current time to the previous time an LED turned on
// if it is greater than your interval, run the if statement
if (currentTime - previousTime > interval) {
// save the current time as the last time you changed an LED
previousTime = currentTime;
Serial.print ( "LED: "); // staat niet in handleiding
Serial.println (led); // staat niet in handleiding
// Turn the LED on
digitalWrite(led, HIGH);
// increment the led variable
// in 10 minutes the next LED will light up
led++;
if (led > 7) {
led = 2 ; // staat niet in de handleiding
// the hour is up
}
}
// read the switch value
switchState = digitalRead(switchPin);
// if the switch has changed
if (switchState != prevSwitchState) {
// turn all the LEDs low
for (int x = 2; x < 8; x++) {
digitalWrite(x, LOW);
}
// reset the LED variable to the first one
led = 2;
//reset the timer
previousTime = currentTime;
}
// set the previous switch state to the current state
prevSwitchState = switchState;
}
Misschien is het nuttig ook forum.arduino.cc hierover iets te laten weten.
Beste dank
11 berichten
• Pagina 1 van 2 • 1, 2
Wie is er online?
Gebruikers in dit forum: ikufiwuf en 90 gasten