From: eaman Date: Fri, 9 Oct 2015 15:59:09 +0000 (+0200) Subject: Pre Vicenza X-Git-Url: http://git.piffa.net/web?a=commitdiff_plain;h=f2798a8e8a34fac133b9f37b620af585ee33ba10;p=sketchbook_andrea Pre Vicenza --- diff --git a/.gitignore b/.gitignore index 31a7f9b..b673fde 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ TODO push.sh +libraries/aero/ diff --git a/RGB_LED/rgb_1_all_color/rgb_1_all_color.ino b/RGB_LED/rgb_1_all_color/rgb_1_all_color.ino index b88d0da..a53a02a 100644 --- a/RGB_LED/rgb_1_all_color/rgb_1_all_color.ino +++ b/RGB_LED/rgb_1_all_color/rgb_1_all_color.ino @@ -12,7 +12,7 @@ int greenPin = 10; int bluePin = 9; //uncomment this line if using a Common Anode LED -//#define COMMON_ANODE +#define COMMON_ANODE void setup() { diff --git a/basic/analog_input/analogInput_1/analogInput_1.ino b/basic/analog_input/analogInput_1/analogInput_1.ino index 28547d5..ac477bb 100644 --- a/basic/analog_input/analogInput_1/analogInput_1.ino +++ b/basic/analog_input/analogInput_1/analogInput_1.ino @@ -25,6 +25,8 @@ http://arduino.cc/en/Tutorial/AnalogInput + Schema: http://lab.piffa.net/schemi/potenziometro_bb.png + */ int sensorPin = A0; // select the input pin for the potentiometer diff --git a/basic/blinks/blink_5_2_leds/blink_5_2_leds.ino b/basic/blinks/blink_5_2_leds/blink_5_2_leds.ino index 36ad89d..34b0c94 100644 --- a/basic/blinks/blink_5_2_leds/blink_5_2_leds.ino +++ b/basic/blinks/blink_5_2_leds/blink_5_2_leds.ino @@ -10,7 +10,11 @@ R = (5v-1.8v) / 0.010a R =320ohms - This example code is in the public domain. + + Schema: http://lab.piffa.net/schemi/led_single_bb.png + - http://lab.piffa.net/schemi/led_single_schem.png + + This example code is in the public domain. */ // Pin 13 has an LED connected on most Arduino boards. diff --git a/hardware/joystick/joystick.ino b/hardware/joystick/joystick.ino new file mode 100644 index 0000000..ae9c7ba --- /dev/null +++ b/hardware/joystick/joystick.ino @@ -0,0 +1,46 @@ +/* Joystick +Utilizzo di un joystick analogico con arduino. +da: http://42bots.com/tutorials/arduino-joystick-module-example/ + +Il joystich ha 2 potenziometri analogici e un interruttore digitale +corrispondente alla pressione dello stick (input momentaneo). + + */ +int xPin = A1; +int yPin = A0; +int buttonPin = 2; + +int xPosition = 0; +int yPosition = 0; +int buttonState = 0; + +void setup() { + // initialize serial communications at 9600 bps: + Serial.begin(9600); + + pinMode(xPin, INPUT); + pinMode(yPin, INPUT); + + //activate pull-up resistor on the push-button pin + pinMode(buttonPin, INPUT_PULLUP); + + // For versions prior to Arduino 1.0.1 + // pinMode(buttonPin, INPUT); + // digitalWrite(buttonPin, HIGH); + +} + +void loop() { + xPosition = analogRead(xPin); + yPosition = analogRead(yPin); + buttonState = digitalRead(buttonPin); + + Serial.print("X: "); + Serial.print(xPosition); + Serial.print(" | Y: "); + Serial.print(yPosition); + Serial.print(" | Button: "); + Serial.println(buttonState); + + delay(100); // add some delay between reads +} \ No newline at end of file diff --git a/motors/servo/Knob_2/Knob_2.ino b/motors/servo/Knob_2/Knob_2.ino index 886e107..998c8a7 100644 --- a/motors/servo/Knob_2/Knob_2.ino +++ b/motors/servo/Knob_2/Knob_2.ino @@ -7,7 +7,7 @@ Servo myservo; // create servo object to control a servo int potpin = 0; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin - + void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object diff --git a/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino b/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino index 5f5f2ab..63a324e 100644 --- a/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino +++ b/multitasking/BlinkWithoutDelay_3_funzione/BlinkWithoutDelay_3_funzione.ino @@ -23,9 +23,9 @@ long intervalA = 1000; // interval at which to blink (milliseconds) ////////////// // Second LED int ledB = 12; //Secondo LED -int ledStateB = LOW; // ledState used to set the LED + // ledState used to set the LED long previousMillisB = 0; // will store last time LED was updated -long intervalB = 500; // interval at which to blink (milliseconds) + // interval at which to blink (milliseconds) void setup() { @@ -60,6 +60,8 @@ void lightLedA () { } void lightLedB () { + long intervalB = 500; + static int ledStateB ; if(millis() - previousMillisB > intervalB) { // save the last time you blinked the LED previousMillisB = millis(); diff --git a/multitasking/BlinkWithoutDelay_5_cleanup/BlinkWithoutDelay_5_cleanup.ino b/multitasking/BlinkWithoutDelay_5_cleanup/BlinkWithoutDelay_5_cleanup.ino index 70e9162..17fe931 100644 --- a/multitasking/BlinkWithoutDelay_5_cleanup/BlinkWithoutDelay_5_cleanup.ino +++ b/multitasking/BlinkWithoutDelay_5_cleanup/BlinkWithoutDelay_5_cleanup.ino @@ -63,7 +63,7 @@ void lightLedB (int interval) { /* Approfondimenti - integrazione tra funzioni e dati: programmazione a oggetti - - Uso di pointers per modificare dati esterni allo scope della funzione + - Uso di pointers per modificare dati esterni allo scope della funzione, static - Uso di forme di dati strutturate (array, struct) per scambiare dati tra funzioni e programma */ diff --git a/programming/operators/operator_2_comparison/operator_2_comparison.ino b/programming/operators/operator_2_comparison/operator_2_comparison.ino index 62243f9..7900d9e 100644 --- a/programming/operators/operator_2_comparison/operator_2_comparison.ino +++ b/programming/operators/operator_2_comparison/operator_2_comparison.ino @@ -25,7 +25,7 @@ void setup() // run once, when the sketch starts Serial.println(a > b); Serial.print("a < b = "); // minore - Serial.println(a < c); + Serial.println(a < b); Serial.print("a == b -> "); // stesso valore Serial.println(a == b); @@ -34,10 +34,10 @@ void setup() // run once, when the sketch starts Serial.println(a != b); Serial.print("a <= b ->"); // minore uguale - Serial.println(b <= a); + Serial.println(a <= b); Serial.print("a >= b -> "); // maggiore uguale - Serial.println(b >= a); + Serial.println(a >= b); } void loop() // we need this to be here even though its empty