allora, per Standard:
ho un collegamento sul Desktop che mi lancia la IDE, ho WIN 10 Pro...se faccio uno sketch nuovo mi da 'errore di compilazione'
per Guglielmo: 'la stupidità umana (per esempio la mia) è come l'universo, ha dimensioni astronomiche ed è in continua espansione', ma ci sto lavorando...
#include <Keyboard.h>
int abilitaBlink [] = {0, 0, 0, 0, 0, 0, 0};
int BlinkCounter [] = {0, 0, 0, 0, 0, 0, 0};
int Blink [] = {0, 0, 0, 0, 0, 0, 0};
unsigned long previous = 0;
unsigned long timer = 200;
int Switch[] = {51, 50, 49, 48, 5, 4, 3, 2};
int SwitchState[] = {0, 0, 0, 0, 0, 0, 0, 0};
int Square[] = {47, 45, 43, 41, 9, 17, 19};
int SquareLed[] = {39, 44, 42, 40, 8, 18, 7};
int SquareState[] = {0, 0, 0, 0, 0, 0, 0};
int Last[] = {LOW, LOW, LOW, LOW, LOW, LOW, LOW};
char SwitchPrint[] = {'5', '4', '7', '8', '0', '0', '0', '3'};
char SquarePrint[] = {'N', 'G', '0', 'U', 'L', '0', '0',};
int i = 0;
int Switchstate = 0;
int Squarestate = 0;
int power = 38;
int powerState = 0;
int lastpowerState = 0;
int function = 22;
int functionState = 0;
int lastfunctionState = 0;
int eject = 24;
int ejectState = 0;
int lastejectState = 0;
unsigned long current = millis();
void setup()
{
pinMode (power, INPUT);
pinMode (function, INPUT);
pinMode (eject, INPUT);
for (int i = 0; i < 7; i++)
{
pinMode (Square[i], INPUT);
pinMode (SquareLed [i], OUTPUT);
}
for (int i = 0; i < 8; i++)
{
pinMode (Switch[i], INPUT);
}
}
void BlinkLed(int i)
{
if (((millis() - previous > timer) && (abilitaBlink[i] == 1 && BlinkCounter[i] < 6)))
{
previous = millis();
SquareState [i] ^= 1;
if
(SquareState [i] == HIGH)
{
BlinkCounter[i] ++;
}
digitalWrite (SquareLed [i], SquareState [i]);
if (BlinkCounter[i] >= 5)
{
abilitaBlink[i] = 0;
BlinkCounter[i] = 0;
}
}
}
void loop()
{
{
powerState = digitalRead (power);
if ((powerState != lastpowerState) && (powerState == HIGH))
{
lastpowerState = powerState;
}
if (powerState == HIGH)
{ for (i = 0; i < 7; i++)
if (abilitaBlink [i] == 0)
{
digitalWrite (SquareLed [i], HIGH);
}
}
else
{
for (i = 0; i < 7; i++)
digitalWrite(SquareLed[i], LOW);
}
{
functionState = digitalRead (function);
if
(functionState != lastfunctionState )
{
Keyboard.begin();
Keyboard.print ('P');
Keyboard.end();
delay (50);
}
lastfunctionState = functionState;
for ( i = 0; i < 8; i++)
{
Switchstate = digitalRead (Switch[i]);
if (Switchstate != SwitchState[i])
{
Keyboard.begin();
Keyboard.print (SwitchPrint [i]);
Keyboard.end();
delay (50);
}
SwitchState[i] = Switchstate;
}
for ( i = 0; i < 7; i++)
{
Squarestate = digitalRead (Square[i]);
if ((Squarestate != Last[i]) && (Squarestate == HIGH))
{
abilitaBlink[i] = 1;
Keyboard.begin();
Keyboard.print (SquarePrint [i]);
Keyboard.end();
delay (500);
}
BlinkLed(i);
Last[i] = Squarestate;
}
{
ejectState = digitalRead (eject);
if ((ejectState != lastejectState) && (ejectState == LOW))
{
current = millis();
}
if ((ejectState != lastejectState) && (ejectState == HIGH) && (millis() - current < 3000 ))
{
Keyboard.begin();
Keyboard.print ('9');
Keyboard.end();
}
lastejectState = ejectState;
}
delay (50);
}
}
}