push.sh
libraries/aero/
*.swp
+*Makefile
+*tags
- connessione seriale via radio
- programmare un Attiny85 con Arduino
- ethernet e WIFI
+
+Makefile
+============
+
+Avendo installato il pacchetto ``arduino-mk``, con l'IDE /usr/local/software/arduino-1.6.5 , Arduino.mk resta quello originale della distribuzione posto in /usr/share/arduino/ .
+
+/usr/share/arduino/Makefile ::
+
+ # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile
+
+ BOARD_TAG = uno
+ MONITOR_PORT = /dev/ttyACM0
+
+ CURRENT_DIR = $(shell pwd)
+ OBJDIR = /tmp/$(notdir $(shell pwd))
+ ARDUINO_DIR = /usr/local/software/arduino-1.6.5
+ MONITOR_BAUDRATE = 115200
+
+ include /usr/share/arduino/Arduino.mk
Schema: http://lab.piffa.net/schemi/rgb.jpg
*/
-int redPin = 11;
-int greenPin = 10;
-int bluePin = 9;
+int redPin = 11; // 2v a 20ma: che resistenza dovro usare?
+int greenPin = 10; // 3.5v a 20ma: che resistenza dovro usare?
+int bluePin = 9; // 3.5v a 20ma: che resistenza dovro usare?
common anode
*/
-int redPin = 11;
-int greenPin = 10;
-int bluePin = 9;
-
+int redPin = 11; // 2v a 20ma: che resistenza dovro usare?
+int greenPin = 10; // 3.5v a 20ma: che resistenza dovro usare?
+int bluePin = 9; // 3.5v a 20ma: che resistenza dovro usare?
void setup()
unsigned long currentMillis ;
int steps_left=4095;
long time;
+
+void SetDirection();
+void stepper(int xw);
+
void setup()
{
Serial.begin(115200);
+
/*
- Melody keyboard with Input Pullup Serial
+ Melody keyboard with Input Pullup
Plays a pitch that changes based on 3 digital inputs
-
- This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a
+
+ This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a
digital input on pin 2 and prints the results to the serial monitor.
-
+ There's also an extensive use of arrays.
+
Thecircuit:
* 3 buttons in pin 2,3,4 with no resistors
* Piezo on digital pin 9
* Serial debug is available
-
+
This example code is in the public domain
-
+
Circuit: http://lab.piffa.net/schemi/piezo_2_keyboard_bb.png
-
- */
+ */
-int input[]= {
- 1,2,3};
-int notes[] = {
- 262, 392,880 }; // suona una prima, quinta, ottava in C4
+const int tasti[]= {4,3,2}; // La nota piu' a sx e' quella piu' bassa
+const int notes[] = {262, 392, 880}; // suona una prima, quinta, ottava in C4
+const int piezo_pin = 9;
// Carica un file di esempio con tutte le note
// #include "pitches.h";
// int notes[] = {NOTE_C4, NOTE_G4,NOTE_C5 }; // suona una prima, quinta, ottava
-void setup(){
- //start serial connection
- Serial.begin(9600);
- //configure pin2/3/4 as an input and enable the internal pull-up resistor
- pinMode(2, INPUT_PULLUP);
- pinMode(3, INPUT_PULLUP);
- pinMode(4, INPUT_PULLUP);
- pinMode(9, OUTPUT);
+void setup() {
+ //start serial connection
+ Serial.begin(9600);
+ Serial.println("Welcome");
+ //configure pin2/3/4 as an input and enable the internal pull-up resistor
+ pinMode(tasti[0], INPUT_PULLUP);
+ pinMode(tasti[1], INPUT_PULLUP);
+ pinMode(tasti[2], INPUT_PULLUP); // Provare ad impostare i PIN con un
+ // ciclo for
+ pinMode(9, OUTPUT);
}
-void loop(){
- for (int thisSensor = 2; thisSensor < 5; thisSensor++) {
- int sensorReading = digitalRead(thisSensor);
- if (sensorReading == LOW) {
- Serial.println(thisSensor);
- tone(9, notes[thisSensor -2], 50); // Notes array is translated
+void loop() {
+ for (int thisSensor = 0; thisSensor < 3; thisSensor++) {
+ int sensorReading = digitalRead(tasti[thisSensor]);
+ if (sensorReading == LOW) {
+ Serial.print("Sensore: ");
+ Serial.print(thisSensor);
+ tone(piezo_pin, notes[thisSensor ], 50); // Notes array is translated
+ Serial.print("\t Nota: ");
+ Serial.println(notes[thisSensor]);
+ }
+ //delay(2); // eventuale delay
}
- //delay(2); // eventuale delay
- }
}
/* Domande
1. Modificare le note suonate utilizzando come riferimento il file pitches.h:
- suonare una prima, terza, quinta (C-E-G)
- 2. Includere il file pitches.h . Come si potrebbe scrivere una melodia da far suonare
- autnomamente ad Arduino?
+ suonare una prima, terza, quinta (C-E-G)
+ 2. Includere il file pitches.h . Come si potrebbe scrivere una melodia da far s uonare autnomamente ad Arduino?
*/
+
+
+
+
+
+
--- /dev/null
+/* Knight Rider 1
+ * --------------
+ *
+ * Basically an extension of Blink_LED.
+ *
+ *
+ * (cleft) 2005 K3, Malmo University
+ * @author: David Cuartielles
+ * @hardware: David Cuartielles, Aaron Hallborg
+ See: https://www.arduino.cc/en/Tutorial/KnightRider
+
+ Schema semplificato:
+ - http://lab.piffa.net/schemi/8_led_single_res_bb.png
+ - http://lab.piffa.net/schemi/8_led_single_res_schem.png
+ */
+
+int pin2 = 2;
+int pin3 = 3;
+int pin4 = 4;
+int pin5 = 5;
+int pin6 = 6;
+int pin7 = 7;
+int pin7 = 8;
+int pin7 = 9;
+int timer = 100;
+
+void setup(){
+ pinMode(pin2, OUTPUT);
+ pinMode(pin3, OUTPUT);
+ pinMode(pin4, OUTPUT);
+ pinMode(pin5, OUTPUT);
+ pinMode(pin6, OUTPUT);
+ pinMode(pin7, OUTPUT);
+ pinMode(pin8, OUTPUT);
+ pinMode(pin9, OUTPUT);
+}
+
+void loop() {
+ digitalWrite(pin2, HIGH);
+ delay(timer);
+ digitalWrite(pin2, LOW);
+ delay(timer);
+
+ digitalWrite(pin3, HIGH);
+ delay(timer);
+ digitalWrite(pin3, LOW);
+ delay(timer);
+
+ digitalWrite(pin4, HIGH);
+ delay(timer);
+ digitalWrite(pin4, LOW);
+ delay(timer);
+
+ digitalWrite(pin5, HIGH);
+ delay(timer);
+ digitalWrite(pin5, LOW);
+ delay(timer);
+
+ digitalWrite(pin6, HIGH);
+ delay(timer);
+ digitalWrite(pin6, LOW);
+ delay(timer);
+
+ digitalWrite(pin7, HIGH);
+ delay(timer);
+ digitalWrite(pin7, LOW);
+ delay(timer);
+
+ digitalWrite(pin8, HIGH);
+ delay(timer);
+ digitalWrite(pin8, LOW);
+ delay(timer);
+
+ digitalWrite(pin9, HIGH);
+ delay(timer);
+ digitalWrite(pin9, LOW);
+ delay(timer);
+
+ // Ding! Mezzo giro
+
+ digitalWrite(pin8, HIGH);
+ delay(timer);
+ digitalWrite(pin8, LOW);
+ delay(timer);
+
+ digitalWrite(pin7, HIGH);
+ delay(timer);
+ digitalWrite(pin7, LOW);
+ delay(timer);
+
+ digitalWrite(pin6, HIGH);
+ delay(timer);
+ digitalWrite(pin6, LOW);
+ delay(timer);
+
+ digitalWrite(pin5, HIGH);
+ delay(timer);
+ digitalWrite(pin5, LOW);
+ delay(timer);
+
+ digitalWrite(pin4, HIGH);
+ delay(timer);
+ digitalWrite(pin4, LOW);
+ delay(timer);
+
+ digitalWrite(pin3, HIGH);
+ delay(timer);
+ digitalWrite(pin3, LOW);
+ delay(timer);
+}
--- /dev/null
+/* Knight Rider 2
+ * --------------
+ *
+ * Reducing the amount of code using for(;;).
+ *
+ *
+ * (cleft) 2005 K3, Malmo University
+ * @author: David Cuartielles
+ * @hardware: David Cuartielles, Aaron Hallborg
+
+
+ Schema semplificato:
+ - http://lab.piffa.net/schemi/8_led_single_res_bb.png
+ - http://lab.piffa.net/schemi/8_led_single_res_schem.png
+ */
+
+int pinArray[8] = {2, 3, 4, 5, 6, 7, 8, 9};
+int count = 0;
+int timer = 100;
+
+void setup(){
+ // we make all the declarations at once
+ for (count=0;count<9;count++) {
+ pinMode(pinArray[count], OUTPUT);
+ }
+}
+
+void loop() {
+ for (count=0;count<8;count++) { // 8 e' un numero magico
+ digitalWrite(pinArray[count], HIGH);
+ delay(timer);
+ digitalWrite(pinArray[count], LOW);
+ delay(timer);
+ }
+ for (count=8;count>=0;count--) {
+ digitalWrite(pinArray[count], HIGH);
+ delay(timer);
+ digitalWrite(pinArray[count], LOW);
+ delay(timer);
+ }
+}
+
+/* Domande:
+
+ 1. Come posso fare per saltare un elemento del loop?
+ 2. Come posso fare per uscire completamente dal loop?
+ 3. 8 e' un numero magico: come posso evitarlo?
+
+.
+.
+.
+.
+.
+.
+.
+.
+.
+.
+.
+Soluzioni:
+ 1. utilizzare continue
+ 2. utilizzare break
+ 3. Utilizzare un variabile sarebbe gia' un inizio, ancora meglio estrarre il
+ valore tramite la funzione sizeof().
+Links:
+- http://www.tutorialspoint.com/cprogramming/c_continue_statement.htm
+- https://www.arduino.cc/en/Reference/Sizeof
+*/
+
+