Qualche esercizio per il corso di Scratch.
Dopo l’albero, le luci di Natale
Dopo l’albero di Natale con Scratch, ecco le luci di Natale con Arduino:
Il relativo codice (migliorabilissimo):
/* Arrays Demonstrates the use of an array to hold pin numbers in order to iterate over the pins in a sequence. Lights multiple LEDs in sequence, then in reverse. Unlike the For Loop tutorial, where the pins have to be contiguous, here the pins can be in any random order. The circuit: * LEDs from pins 3 through 11 to ground created 2006 by David A. Mellis modified 30 Aug 2011 by Tom Igoe modified 08 Dec 2014 by Gaspar Torriero The original code is in the public domain. http://www.arduino.cc/en/Tutorial/Array */ int N; int timer = 100; // The higher the number, the slower the timing. int selector = 4; int ledPins0[] = { 3, 4, 5, 6, 7, 8, 9, 10, 11}; // an array of pin numbers to which LEDs are attached int ledPins1[] = { 3, 6, 9, 4, 7, 10, 5, 8, 11}; // an array of pin numbers to which LEDs are attached int ledPins2[] = { 3, 11, 4, 10, 5, 9, 6, 8, 7}; // an array of pin numbers to which LEDs are attached int ledPins3[] = { 3, 5, 7, 9, 11, 4, 6, 8, 10}; // an array of pin numbers to which LEDs are attached int pinCount = 9; // the number of pins (i.e. the length of the array) void setup() { for (int N = 3; N < 12; N++) { pinMode(N,OUTPUT); } } void loop() { timer = analogRead(A0); // one of the next two lines must be uncommented selector = (analogRead(A1) / 255); // knob-selected status //selector = random(3); //random status if (selector == 0) { // loop from the lowest pin to the highest: for (int thisPin = 0; thisPin < pinCount; thisPin++) { // turn the pin on: digitalWrite(ledPins0[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins0[thisPin], LOW); } // loop from the highest pin to the lowest: for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { // turn the pin on: digitalWrite(ledPins0[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins0[thisPin], LOW); } } else if (selector == 1) { // loop from the lowest pin to the highest: for (int thisPin = 0; thisPin < pinCount; thisPin++) { // turn the pin on: digitalWrite(ledPins1[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins1[thisPin], LOW); } // loop from the highest pin to the lowest: for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { // turn the pin on: digitalWrite(ledPins1[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins1[thisPin], LOW); } } if (selector == 2) { // loop from the lowest pin to the highest: for (int thisPin = 0; thisPin < pinCount; thisPin++) { // turn the pin on: digitalWrite(ledPins2[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins2[thisPin], LOW); } // loop from the highest pin to the lowest: for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { // turn the pin on: digitalWrite(ledPins2[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins2[thisPin], LOW); } } else if (selector == 3) { // loop from the lowest pin to the highest: for (int thisPin = 0; thisPin < pinCount; thisPin++) { // turn the pin on: digitalWrite(ledPins3[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins3[thisPin], LOW); } // loop from the highest pin to the lowest: for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { // turn the pin on: digitalWrite(ledPins3[thisPin], HIGH); delay(timer); // turn the pin off: digitalWrite(ledPins3[thisPin], LOW); } } }
Arduino al Coder Dojo Ticino
Metto qui le slide che userò domani al Coder Dojo Ticino. Partiremo seguendo i capitoli 1 e 2 del libro dei progetti dello Starter Kit per prendere confidenza col mezzo, e proseguiremo con Scratchbot che è una versione appositamente modificata di Scratch per interagire con Arduino.
Tra parentesi: oggi è il compleanno di questo blogghettino, nato il 7 novembre 2001. 3.169 post, e non mi sono ancora stufato.
Corso online: Making Sense of Data
Ti segnalo questa buona iniziativa di Google: Making Sense of Data: si tratta di un corso online attivo dal 18 marzo al 4 aprile in cui vengono spiegati i fondamentali sulla raccolta e analisi di dati con le Fusion Tables.
Il corso è di livello base, si rivolge a chi non ha esperienza di analisi statistica e può essere completato in un pomeriggio. Superando il test finale si ottiene un certificate of completion.
Unica avvertenza: per qualche misterioso motivo, se ti iscrivi con un account di Google Apps for Domains le Fusion Tables non ti funzionano e non puoi completare gli esercizi. Bisogna iscriversi con un account @google.com, come mi hanno spiegato (dopo).
Tra parentesi, cosa aspettano a integrare Fusion con i fogli di calcolo di Google Drive? Ne verrebbe fuori una web app assai interessante.
Dei Commenti e delle pene
Su internet ci sono miliardi di pagine che non potrai mai vedere: non ne hai il tempo, ma neanche la voglia. La tua esperienza di internet è per forza molto parziale e soggettiva, e puoi senz’altro dire che esistono tante internet quante sono i suoi utenti.
Allo stesso modo il tuo orecchio seleziona, nel brusio della folla, le voci delle persone a cui hai scelto di stare vicino, e non c’è bisogno di imporre a tutti il silenzio; e se qualcuno parla a voce troppo alta, fai prima e meglio a spostarti di qualche metro che non ad andare a dargli del cretino.
Questa cosa si chiama “filtro a posteriori” e fa parte del bello di internet: tutti possono dire tutto, ma le idee per te poco belle vengono rapidamente scartate a favore di quelle interessanti.
Il punto quindi non è chiedersi se su internet ci sia violenza, la risposta ovviamente è “Certamente, dato che c’è di tutto!”. La domanda importante è “C’è violenza nella mia internet? E cosa posso fare per ridurla?”.
Per mia esperienza, la violenza su internet è figlia delle folle, e in particolare delle folle che non sono comunità. I siti che attirano un gran numero di persone che non si conoscono tra di loro, quando aprono i commenti, scatenano le più basse pulsioni della gente normale e attirano le persone più disturbate. Il problema di fondo è che questi siti guadagnano dalla grande quantità di utenti e non hanno nessun incentivo a moderare.
Allora il mio consiglio per evitare la violenza su internet è questo: evita le folle. Evita i commenti non moderati. Evita di dare l’amicizia a 5000 sconosciuti su facebook o su Twitter. Vivrai molto meglio.
Aggiornamento:
I commenti sono su facebook