Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
long t1 = 0; | ||
long pausa = 5*1000; | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
t1 = millis(); | ||
Serial.println("inizio pausa"); | ||
} | ||
|
||
void loop() { | ||
long diff = millis() - t1; | ||
if (diff > pausa) { | ||
Serial.println("fine pausa lunga"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const int c = 261; | ||
const int d = 294; | ||
const int e = 329; | ||
const int f = 349; | ||
const int g = 391; | ||
const int gS = 415; | ||
const int a = 440; | ||
const int aS = 455; | ||
const int b = 466; | ||
const int cH = 523; | ||
const int cSH = 554; | ||
const int dH = 587; | ||
const int dSH = 622; | ||
const int eH = 659; | ||
const int fH = 698; | ||
const int fSH = 740; | ||
const int gH = 784; | ||
const int gSH = 830; | ||
const int aH = 880; | ||
|
||
int pin = 6; | ||
|
||
void setup() { | ||
pinMode(pin, OUTPUT); | ||
|
||
tone(pin, a, 500); | ||
delay(500); | ||
tone(pin, b, 500); | ||
delay(500); | ||
tone(pin, c, 500); | ||
delay(500); | ||
tone(pin, d, 500); | ||
delay(500); | ||
} | ||
|
||
void loop() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
int pin = 7; | ||
|
||
void setup() { | ||
pinMode(pin, OUTPUT); | ||
|
||
} | ||
|
||
void loop() { | ||
int nota = random(200, 1000); | ||
tone(pin, nota, 100); | ||
delay(100); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Arduino Cookbook - di Paolo Aliverti | ||
www.zeppelinmaker.it | ||
Effetto di break e continue | ||
*/ | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
|
||
Serial.println("FOR - uso di break "); | ||
for (int j = 0; j < 10; j++){ | ||
if (j == 5) break; | ||
Serial.print("j: "); | ||
Serial.println(j); | ||
} | ||
Serial.println("FOR - uso di continue "); | ||
for (int j = 0; j < 10; j++){ | ||
if (j == 5) continue; | ||
Serial.print("j: "); | ||
Serial.println(j); | ||
} | ||
|
||
Serial.println("WHILE - uso di break "); | ||
int i = 0; | ||
while (i < 10) { | ||
Serial.print("i: "); | ||
Serial.println(i); | ||
if (i == 5) break; | ||
i++; | ||
} | ||
Serial.print("uscito con i: "); | ||
Serial.println(i); | ||
|
||
i = 0; //riazzero i | ||
Serial.println("WHILE - uso di continue "); | ||
while (i < 10) { | ||
if (i == 5) { | ||
i++; | ||
continue; | ||
} | ||
Serial.print("i: "); | ||
Serial.println(i); | ||
i++; | ||
} | ||
|
||
} | ||
|
||
void loop(){} |
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//int pin = 14; //A0 | ||
int pin = 19; //A5 | ||
|
||
void setup() { | ||
pinMode(pin, OUTPUT); | ||
|
||
} | ||
|
||
void loop() { | ||
digitalWrite(pin, HIGH); | ||
delay(500); | ||
digitalWrite(pin, LOW); | ||
delay(500); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <CapacitiveSensor.h> | ||
|
||
//La libreria fornisce un oggetto da inizializzare con i pin digitali da usare | ||
//il sensore va collegato sul pin 11 | ||
// tra 10 e 11 c'è una resistenza da 10Mohm | ||
CapacitiveSensor touch = CapacitiveSensor(10,11); | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
pinMode(13, OUTPUT); | ||
//disattiva l'autocalibrazione del sensore ??????? | ||
touch.set_CS_AutocaL_Millis(0xFFFFFFFF); | ||
} | ||
|
||
void loop() { | ||
//leggo il valore registrato dal sensore e specifico di fare 30 campionamenti | ||
long value = touch.capacitiveSensor(30); | ||
Serial.println(value); | ||
if (value > 100) { | ||
digitalWrite(13, HIGH); | ||
} else { | ||
digitalWrite(13, LOW); | ||
} | ||
delay(10); | ||
} |