There are several LEDs and Buttons on the processor board of the Macchina M2. These are user programmable and can be used for many applications.
M2 has 5 single-color LEDs and 1 RGB LED. Each LED is active LOW - the processor needs to pull the pin LOW to turn on the LED.
The following table shows what LEDs correspond to what Pin name.
LED | Mapped Pin Name |
DS2 (RED) | DS2 |
DS3 (YELLOW) | DS3 |
DS4 (YELLOW) | DS4 |
DS5 (YELLOW) | DS5 |
DS6 (GREEN) | DS6 |
RGB RED | DS7_RED / RGB_RED |
RGB GREEN | DS7_GREEN / RGB_GREEN |
RGB BLUE | DS7_BLUE / RGB_BLUE |
For example, if you want the Green LED to blink, this sketch will do that for you:
void setup() {// initialize digital pin DS6 as an output.pinMode(DS6, OUTPUT);}// the loop function runs over and over again forevervoid loop() {digitalWrite(DS6, LOW); // turn the LED on (LOW is the voltage level)delay(1000); // wait for a seconddigitalWrite(DS6, HIGH); // turn the LED off by making the voltage HIGHdelay(1000); // wait for a second}
M2 has 4 buttons on the Processor board.
2 of these buttons (Button1 and Button2) are user-programmable. Use these for triggering something in your program. For example, this code turns on the Red LED when Button 1 is pressed:
const int buttonPin = Button1; // the number of the pushbutton pinconst int ledPin = DS2; // the number of the LED pinint buttonState = 0; // variable for reading the pushbutton statusvoid setup() {pinMode(ledPin, OUTPUT);pinMode(buttonPin, INPUT);}void loop() {buttonState = digitalRead(buttonPin);if (buttonState == LOW) { // If button is presseddigitalWrite(ledPin, LOW); // Turn the Red LED on} else {digitalWrite(ledPin, HIGH); // Turn the Red LED off}}
RESET button will reset the processor.
ERASE button is used in conjunction with the RESET button. In the event your program hangs or there is some other issue, power up M2, hold down ERASE and then press and release RESET. This will erase the flash on the processor.