TonUINO All-In-One – Einen neuen Sketch erstellen

Veröffentlicht am

Nachdem ihr die Arduino-IDE eingerichtet habt könnt ihr einen neuen Sketch erstellen. Wir haben einige Pins definiert die die Komponenten auf der Platine fest miteinander verbindet.

Damit sich die Platine nicht sofort wieder ausschaltet wird der entsprechende Code in der setup()-Methode benötigt. Ausschalten könnt ihr die Platine indem ihr die powerOff()-Methode aufruft.

/*
   empty sketch to start a project
   D5, A6 and A7 are wired to the extension port.
   D6 is wired to the button breakout board (labled WS(D6)).
   D9 (RST), D10 (SDA), D11 (MOSI), D12 (MISO) and D13 (SCK) are wired to the nfc breakout board.
   the rest of the pins are hard wired as per below.
*/

const uint8_t mp3SerialRxPin = 2;                   // mp3 serial rx, wired to tx pin of the mp3 chip
const uint8_t mp3SerialTxPin = 3;                   // mp3 serial tx, wired to rx pin of the mp3 chip
const uint8_t busyPin = 4;                          // reports play state of the mp3 chip (HIGH = not playing, LOW = playing)
const uint8_t powerControlPin = 7;                  // control pin used to power the system (HIGH = power on, LOW = power off)
const uint8_t onboardAmpControlPin = 8;             // control pin of the onboard amp (HIGH = amp off, LOW = amp on)
const uint8_t button0Pin = A0;                      // play/pause/power on
const uint8_t button1Pin = A1;                      // prev
const uint8_t button2Pin = A2;                      // next
const uint8_t button3Pin = A3;                      // vol-
const uint8_t button4Pin = A4;                      // vol+
const uint8_t onboardSdAccessControlPin = A5;       // control pin of the external sd card access (HIGH = enabled, LOW = disabled)

void setup() {
  // keep board powered
  pinMode(powerControlPin, OUTPUT);
  digitalWrite(powerControlPin, HIGH);
  // switch sd access off
  pinMode(onboardSdAccessControlPin, OUTPUT);
  digitalWrite(onboardSdAccessControlPin, LOW);
}

void powerOff() {
  // set the powerControlPin to LOW to switch off the board
  digitalWrite(powerControlPin, LOW);
}

void loop() {
  // do some cool stuff!
}