Hashtag più usati
1 | #include |
2 | #drone |
3 | #ets2 |
4 | #eurotrucksimulator2 |
5 | #dlcitalia |
6 | #arduino |
7 | #xiaomi |
8 | #aukey |
9 | #farmingsimulator |
Ultimi argomenti attivi
» Comunicazione termine servizio Arduino BT ControlDa Admin Mar Mag 10, 2022 12:55 pm
» Robot aspirapolvere per Alexa: Dreame D9
Da Admin Mar Feb 09, 2021 9:42 am
» Come costruire un robot smart con Arduino
Da Admin Mar Nov 17, 2020 12:15 pm
» TOPPS Trading Cards Match Attax Champsion League/Europa League 2020/21
Da Admin Mar Nov 10, 2020 3:21 pm
» Guida per utilizzare Arduino BT Control v1.2
Da Admin Gio Lug 09, 2020 12:01 pm
» Recensione Umidigi A3 Pro - Smartphone sotto i 100€
Da Admin Gio Apr 04, 2019 12:22 pm
» [Arduino] aiuto programma
Da Glak Mar Mar 12, 2019 9:30 am
» ERRORE NELLA COMPILAZIONE NEXTION
Da papat Mar Feb 26, 2019 7:11 am
» Comandare la Smart TV con Alexa senza broadlink (gratis)
Da Admin Mar Feb 19, 2019 4:31 pm
I postatori più attivi del mese
Nessun utente |
sketch non valido
2 partecipanti
Wiki Info :: Altro :: Wiki Info Answers
Pagina 1 di 1
sketch non valido
#include "pitches.h"
const int piezoPin = 12; //piezo
const int rPin = 5; //red LED
const int gPin = 4; //green LED
const int bPin = 3; //blue LED
const int pPin = 2; //pushbutton
int ledState = 0;
int ledOn = false;
// notes
int melody[] = {
NOTE_F5,NOTE_D5,NOTE_AS4,NOTE_D5,NOTE_F5,NOTE_AS5,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_D5,NOTE_E5,NOTE_F5,
NOTE_F5,NOTE_F5,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_A5,NOTE_AS5,NOTE_AS5,NOTE_F5,NOTE_D5,NOTE_AS4,
NOTE_D6,NOTE_D6,NOTE_D6,NOTE_DS6,NOTE_F6,NOTE_F6,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_DS6,
0,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_A5,NOTE_AS5,NOTE_D5,NOTE_E5,NOTE_F5,
NOTE_F5,NOTE_AS5,NOTE_AS5,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_G5,NOTE_G5,NOTE_C6,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_AS5,NOTE_A5,
NOTE_F5,NOTE_F5,NOTE_AS5,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_F6,NOTE_AS5,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_C6,NOTE_AS5
};
// durations: 2 = half note, and 8/3,4,6,8,12. It appears that 8/2.9 is more accurate than 8/3.
float noteDurations[] = {
6,12,4,4,4,2,6,12,4,4,4,2,
8,8,8/2.9,8,4,2,8,8,4,4,4,4,4,
6,12,4,4,4,2,8,8,4,4,4,2,
8,8,8/2.9,8,4,2,8,8,4,4,4,2,
4,4,4,8,8,4,4,4,4,8,8,8,8,4,4,
8,8,8/2.9,8,8,8,2,8,8,4,4,4,2
};
// calculates the number of elements in the melody array.
int musicLength=sizeof(melody)/sizeof('NOTE_F5');
void setup() {
pinMode(pPin, INPUT);
pinMode(rPin, OUTPUT);
pinMode(gPin, OUTPUT);
pinMode(bPin, OUTPUT);
}
void loop() {
int pPinState=digitalRead(pPin);
if(pPinState==HIGH) {
ledState = 1;
}
if (pPinState==LOW and ledState ==1) {
ledState = 2;
ledOn = not ledOn;
}
if (ledOn && pPinState!=HIGH) {
for (int thisNote = 0; thisNote < musicLength; thisNote++) {
// blink the three LEDs in sequence
if (thisNote%3==0){
digitalWrite(rPin, HIGH);
digitalWrite(gPin, LOW);
digitalWrite(bPin, LOW);
}
else if (thisNote%3==1){
digitalWrite(rPin, LOW);
digitalWrite(gPin, HIGH);
digitalWrite(bPin, LOW);
}
else if (thisNote%3==2){
digitalWrite(rPin, LOW);
digitalWrite(gPin, LOW);
digitalWrite(bPin, HIGH);
}
// calculate the note duration. change tempo by changing 2000 to other values
int noteDuration = 2000/noteDurations[thisNote];
tone(piezoPin, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well
float pauseBetweenNotes = noteDuration * 1.30;
//split the delay into two parts and check to see
//whether the pushbutton is pressed to turn off
//the sound and light
delay(pauseBetweenNotes/2);
if(digitalRead(pPin)==HIGH) {
break;
}
delay(pauseBetweenNotes/2);
if(digitalRead(pPin)==HIGH) {
break;
}
}
}
else if (not ledOn) {
digitalWrite(rPin, LOW);
digitalWrite(gPin, LOW);
digitalWrite(bPin, LOW);
}
}
Intanto mi scuso se le modalità di invio non son quelle giuste per il forum....Da un paio di anni ho abbandonato i progetti di Arduino,progetti che ho sempre copiato.Uno di essi era riprodurre con l
led e suoni l'inno USA.Oggi ho ripreso a giocarci ma lo sketch che avevo salvato non funziona.La verifica mi dà questo messaggio: pitches.h no such file or directory.
Invio lo sketch che funzionava bene
Grazie per l'aiuto ed eventuali consigli
#include "pitches.h"
const int piezoPin = 12; //piezo
const int rPin = 5; //red LED
const int gPin = 4; //green LED
const int bPin = 3; //blue LED
const int pPin = 2; //pushbutton
int ledState = 0;
int ledOn = false;
// notes
int melody[] = {
NOTE_F5,NOTE_D5,NOTE_AS4,NOTE_D5,NOTE_F5,NOTE_AS5,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_D5,NOTE_E5,NOTE_F5,
NOTE_F5,NOTE_F5,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_A5,NOTE_AS5,NOTE_AS5,NOTE_F5,NOTE_D5,NOTE_AS4,
NOTE_D6,NOTE_D6,NOTE_D6,NOTE_DS6,NOTE_F6,NOTE_F6,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_DS6,
0,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_A5,NOTE_AS5,NOTE_D5,NOTE_E5,NOTE_F5,
NOTE_F5,NOTE_AS5,NOTE_AS5,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_G5,NOTE_G5,NOTE_C6,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_AS5,NOTE_A5,
NOTE_F5,NOTE_F5,NOTE_AS5,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_F6,NOTE_AS5,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_C6,NOTE_AS5
};
// durations: 2 = half note, and 8/3,4,6,8,12. It appears that 8/2.9 is more accurate than 8/3.
float noteDurations[] = {
6,12,4,4,4,2,6,12,4,4,4,2,
8,8,8/2.9,8,4,2,8,8,4,4,4,4,4,
6,12,4,4,4,2,8,8,4,4,4,2,
8,8,8/2.9,8,4,2,8,8,4,4,4,2,
4,4,4,8,8,4,4,4,4,8,8,8,8,4,4,
8,8,8/2.9,8,8,8,2,8,8,4,4,4,2
};
// calculates the number of elements in the melody array.
int musicLength=sizeof(melody)/sizeof('NOTE_F5');
void setup() {
pinMode(pPin, INPUT);
pinMode(rPin, OUTPUT);
pinMode(gPin, OUTPUT);
pinMode(bPin, OUTPUT);
}
void loop() {
int pPinState=digitalRead(pPin);
if(pPinState==HIGH) {
ledState = 1;
}
if (pPinState==LOW and ledState ==1) {
ledState = 2;
ledOn = not ledOn;
}
if (ledOn && pPinState!=HIGH) {
for (int thisNote = 0; thisNote < musicLength; thisNote++) {
// blink the three LEDs in sequence
if (thisNote%3==0){
digitalWrite(rPin, HIGH);
digitalWrite(gPin, LOW);
digitalWrite(bPin, LOW);
}
else if (thisNote%3==1){
digitalWrite(rPin, LOW);
digitalWrite(gPin, HIGH);
digitalWrite(bPin, LOW);
}
else if (thisNote%3==2){
digitalWrite(rPin, LOW);
digitalWrite(gPin, LOW);
digitalWrite(bPin, HIGH);
}
// calculate the note duration. change tempo by changing 2000 to other values
int noteDuration = 2000/noteDurations[thisNote];
tone(piezoPin, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well
float pauseBetweenNotes = noteDuration * 1.30;
//split the delay into two parts and check to see
//whether the pushbutton is pressed to turn off
//the sound and light
delay(pauseBetweenNotes/2);
if(digitalRead(pPin)==HIGH) {
break;
}
delay(pauseBetweenNotes/2);
if(digitalRead(pPin)==HIGH) {
break;
}
}
}
else if (not ledOn) {
digitalWrite(rPin, LOW);
digitalWrite(gPin, LOW);
digitalWrite(bPin, LOW);
}
}
const int piezoPin = 12; //piezo
const int rPin = 5; //red LED
const int gPin = 4; //green LED
const int bPin = 3; //blue LED
const int pPin = 2; //pushbutton
int ledState = 0;
int ledOn = false;
// notes
int melody[] = {
NOTE_F5,NOTE_D5,NOTE_AS4,NOTE_D5,NOTE_F5,NOTE_AS5,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_D5,NOTE_E5,NOTE_F5,
NOTE_F5,NOTE_F5,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_A5,NOTE_AS5,NOTE_AS5,NOTE_F5,NOTE_D5,NOTE_AS4,
NOTE_D6,NOTE_D6,NOTE_D6,NOTE_DS6,NOTE_F6,NOTE_F6,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_DS6,
0,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_A5,NOTE_AS5,NOTE_D5,NOTE_E5,NOTE_F5,
NOTE_F5,NOTE_AS5,NOTE_AS5,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_G5,NOTE_G5,NOTE_C6,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_AS5,NOTE_A5,
NOTE_F5,NOTE_F5,NOTE_AS5,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_F6,NOTE_AS5,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_C6,NOTE_AS5
};
// durations: 2 = half note, and 8/3,4,6,8,12. It appears that 8/2.9 is more accurate than 8/3.
float noteDurations[] = {
6,12,4,4,4,2,6,12,4,4,4,2,
8,8,8/2.9,8,4,2,8,8,4,4,4,4,4,
6,12,4,4,4,2,8,8,4,4,4,2,
8,8,8/2.9,8,4,2,8,8,4,4,4,2,
4,4,4,8,8,4,4,4,4,8,8,8,8,4,4,
8,8,8/2.9,8,8,8,2,8,8,4,4,4,2
};
// calculates the number of elements in the melody array.
int musicLength=sizeof(melody)/sizeof('NOTE_F5');
void setup() {
pinMode(pPin, INPUT);
pinMode(rPin, OUTPUT);
pinMode(gPin, OUTPUT);
pinMode(bPin, OUTPUT);
}
void loop() {
int pPinState=digitalRead(pPin);
if(pPinState==HIGH) {
ledState = 1;
}
if (pPinState==LOW and ledState ==1) {
ledState = 2;
ledOn = not ledOn;
}
if (ledOn && pPinState!=HIGH) {
for (int thisNote = 0; thisNote < musicLength; thisNote++) {
// blink the three LEDs in sequence
if (thisNote%3==0){
digitalWrite(rPin, HIGH);
digitalWrite(gPin, LOW);
digitalWrite(bPin, LOW);
}
else if (thisNote%3==1){
digitalWrite(rPin, LOW);
digitalWrite(gPin, HIGH);
digitalWrite(bPin, LOW);
}
else if (thisNote%3==2){
digitalWrite(rPin, LOW);
digitalWrite(gPin, LOW);
digitalWrite(bPin, HIGH);
}
// calculate the note duration. change tempo by changing 2000 to other values
int noteDuration = 2000/noteDurations[thisNote];
tone(piezoPin, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well
float pauseBetweenNotes = noteDuration * 1.30;
//split the delay into two parts and check to see
//whether the pushbutton is pressed to turn off
//the sound and light
delay(pauseBetweenNotes/2);
if(digitalRead(pPin)==HIGH) {
break;
}
delay(pauseBetweenNotes/2);
if(digitalRead(pPin)==HIGH) {
break;
}
}
}
else if (not ledOn) {
digitalWrite(rPin, LOW);
digitalWrite(gPin, LOW);
digitalWrite(bPin, LOW);
}
}
Intanto mi scuso se le modalità di invio non son quelle giuste per il forum....Da un paio di anni ho abbandonato i progetti di Arduino,progetti che ho sempre copiato.Uno di essi era riprodurre con l
led e suoni l'inno USA.Oggi ho ripreso a giocarci ma lo sketch che avevo salvato non funziona.La verifica mi dà questo messaggio: pitches.h no such file or directory.
Invio lo sketch che funzionava bene
Grazie per l'aiuto ed eventuali consigli
#include "pitches.h"
const int piezoPin = 12; //piezo
const int rPin = 5; //red LED
const int gPin = 4; //green LED
const int bPin = 3; //blue LED
const int pPin = 2; //pushbutton
int ledState = 0;
int ledOn = false;
// notes
int melody[] = {
NOTE_F5,NOTE_D5,NOTE_AS4,NOTE_D5,NOTE_F5,NOTE_AS5,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_D5,NOTE_E5,NOTE_F5,
NOTE_F5,NOTE_F5,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_A5,NOTE_AS5,NOTE_AS5,NOTE_F5,NOTE_D5,NOTE_AS4,
NOTE_D6,NOTE_D6,NOTE_D6,NOTE_DS6,NOTE_F6,NOTE_F6,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_DS6,
0,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_A5,NOTE_AS5,NOTE_D5,NOTE_E5,NOTE_F5,
NOTE_F5,NOTE_AS5,NOTE_AS5,NOTE_AS5,NOTE_A5,NOTE_G5,NOTE_G5,NOTE_G5,NOTE_C6,NOTE_DS6,NOTE_D6,NOTE_C6,NOTE_AS5,NOTE_AS5,NOTE_A5,
NOTE_F5,NOTE_F5,NOTE_AS5,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_F6,NOTE_AS5,NOTE_C6,NOTE_D6,NOTE_DS6,NOTE_C6,NOTE_AS5
};
// durations: 2 = half note, and 8/3,4,6,8,12. It appears that 8/2.9 is more accurate than 8/3.
float noteDurations[] = {
6,12,4,4,4,2,6,12,4,4,4,2,
8,8,8/2.9,8,4,2,8,8,4,4,4,4,4,
6,12,4,4,4,2,8,8,4,4,4,2,
8,8,8/2.9,8,4,2,8,8,4,4,4,2,
4,4,4,8,8,4,4,4,4,8,8,8,8,4,4,
8,8,8/2.9,8,8,8,2,8,8,4,4,4,2
};
// calculates the number of elements in the melody array.
int musicLength=sizeof(melody)/sizeof('NOTE_F5');
void setup() {
pinMode(pPin, INPUT);
pinMode(rPin, OUTPUT);
pinMode(gPin, OUTPUT);
pinMode(bPin, OUTPUT);
}
void loop() {
int pPinState=digitalRead(pPin);
if(pPinState==HIGH) {
ledState = 1;
}
if (pPinState==LOW and ledState ==1) {
ledState = 2;
ledOn = not ledOn;
}
if (ledOn && pPinState!=HIGH) {
for (int thisNote = 0; thisNote < musicLength; thisNote++) {
// blink the three LEDs in sequence
if (thisNote%3==0){
digitalWrite(rPin, HIGH);
digitalWrite(gPin, LOW);
digitalWrite(bPin, LOW);
}
else if (thisNote%3==1){
digitalWrite(rPin, LOW);
digitalWrite(gPin, HIGH);
digitalWrite(bPin, LOW);
}
else if (thisNote%3==2){
digitalWrite(rPin, LOW);
digitalWrite(gPin, LOW);
digitalWrite(bPin, HIGH);
}
// calculate the note duration. change tempo by changing 2000 to other values
int noteDuration = 2000/noteDurations[thisNote];
tone(piezoPin, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well
float pauseBetweenNotes = noteDuration * 1.30;
//split the delay into two parts and check to see
//whether the pushbutton is pressed to turn off
//the sound and light
delay(pauseBetweenNotes/2);
if(digitalRead(pPin)==HIGH) {
break;
}
delay(pauseBetweenNotes/2);
if(digitalRead(pPin)==HIGH) {
break;
}
}
}
else if (not ledOn) {
digitalWrite(rPin, LOW);
digitalWrite(gPin, LOW);
digitalWrite(bPin, LOW);
}
}
fulvio calvarano- Livello uno
- Messaggi : 15
Crediti : 29
Reputazione : 0
Data d'iscrizione : 03.01.19
Età : 75
Località : Trieste
Re: sketch non valido
Grazie.Scusa il ritardo;ero all'estero.
Risolto
Risolto
fulvio calvarano- Livello uno
- Messaggi : 15
Crediti : 29
Reputazione : 0
Data d'iscrizione : 03.01.19
Età : 75
Località : Trieste
Argomenti simili
» sketch non valido
» Arduino con 2 sketch?
» Sketch servomotori
» Sketch The Game By GringoGrillo
» DUE SKETCH INSIEME? SI PUO' FARE?
» Arduino con 2 sketch?
» Sketch servomotori
» Sketch The Game By GringoGrillo
» DUE SKETCH INSIEME? SI PUO' FARE?
Wiki Info :: Altro :: Wiki Info Answers
Pagina 1 di 1
Permessi in questa sezione del forum:
Non puoi rispondere agli argomenti in questo forum.