Devices & Components
Arduino Uno Rev3
Software & Tools
Unity
MiniLab
Windows 10
Project description
Code
Hello
arduino
communicates with a button in MiniLab: receives the start message and button-clicks, and send texts, colors and sounds.
1#include <MiniLab.h> 2String title = "Hello"; 3 4Push push(1); 5 6void setup () { 7 8 Serial.begin(9600); 9 pinMode(13, OUTPUT); 10} 11 12void loop () { 13 14 delay(100); 15 16 if (Serial.available() == 0) return; 17 int id = MiniLab.readInt(); 18 if (id == MiniLab.id_start) { 19 if (!MiniLab.checkTitle(title)) return; 20 21 return; 22 } 23 if (id == push.id) { 24 25 int state = !digitalRead(13); 26 digitalWrite(13, state); 27 28 push.print(state ? "Hello" : "World"); 29 push.set(state ? yellow : cyan); 30 MiniLab.beepSound(); 31 MiniLab.log("log() is useful for simple display or debugging"); 32 } 33} 34
Comments
Only logged in users can leave comments