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.

ADSL Telecom Italia: la meravigliosa qualità della connessione

Un mese fa mi è arrivato a casa a Como lo scatolino di Sam Knows, un servizio che cerca di misurare il più accuratamente possibile le reali prestazioni dei fornitori di accesso internet nel mondo. I grafici del primo mese di utilizzo non sono incoraggianti.

What is ‘UDP Packet Loss’?

Packet loss is relatively rare in modern networks [e infatti]. That said, some broadband providers have been known to suffer high packet loss at peak times. If this is the case for your ISP, you may find that time sensitive applications such as Voice over IP (VoIP) and online gaming will suffer. Packet loss is recorded as a percentage; lower is better.

ADSL Alice 20Mb di Telecom Italia
ADSL Alice 20Mb di Telecom Italia

What is ‘UDP Latency’?

This test measures how long it takes one packet to be sent to one of our test servers and then return back to you. This can effectively be thought of as the responsiveness of the connection between your home and our servers on the Internet. Times are recorded in milliseconds; lower is better.

ADSL Alice 20Mb di Telecom Italia
ADSL Alice 20Mb di Telecom Italia

 

Per la cronaca, ho una connessione Alice 20 Mega che da qualche mese (da quando a Como hanno messo la fibra fino al marciapiede?) funziona al massimo nominale, mentre l’anno scorso viaggiava tra gli 11 e i 14 Mbit in download.

netgear_2014_10

 

Ci sarebbe l’offerta tuttofibra che promette 30Mb in download e 3Mb in upload nominali, anche se ovviamente “l’effettiva velocità dipende da molteplici e variabili fattori tecnici”. Offerta che potrei anche considerare se riguardasse solo la connessione. Ma invece viene assieme a un sacco di altre cose che non mi interessano:

  • il telefono VoIP che ho già Skype, grazie
  • le chiamate gratuite illimitate ma non più di 50 minuti al giorno
  • I telefoni cordless “a solo 1€” ma se disdici il contratto li paghi 50€
  • Internet Pay “per acquistare online contenuti digitali con addebito sul conto (Telecom Italia, ho da darvi una brutta notizia: c’è già PayPal)

Quindi per ora soprassiedo, aspettando che la perdita di pacchetti UDP scenda a 0 e che la latenza media si attesti sotto i 10ms.

iBeacon trials and errors

Trials:

  • Selected users of the American Airlines app will be sent messages aimed primarily at guiding them round the airport. This will include information about walking time to gates and boarding updates.
    American Airlines says that 65% of passengers arrive at their gate early because they are worried about being late or getting lost.
  • Tesco’s trial began earlier this year in its Chelmsford store. It has said that the technology won’t be used to push out marketing messages, but will instead notify shoppers that their pre-ordered goods are waiting for them.
    Ultimately iBeacons could be a central feature in Tesco’s new beta MyStore app, helping customers to find specific items in-store.

And errors:

  • Initially launched with just 100 users, the trial involved sending marketing messages to customers as they entered one of Eat’s stores.

  • The technology enabled fans at 20 baseball stadiums to check-in at games and receive exclusive offers.

  • Virgin passengers with an electronic boarding pass loaded in their iPhone Passbook app could receive messages relevant to their location within the airport.

  • For example, passengers in the departures section of the airport would be sent special offers such as a commission-free currency exchange.

  • In June Odeon Cinemas announced that it planned to imminently begin trials with iBeacons to welcome people to its cinemas, share information and inform them of special offers.

There is no demand for messages. (*)