Atlas - firmware.ino
Home / systems / arduino / buzzer Lines: 2 | Size: 540 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1const int buzzer = 8; 2 3String cmd = ""; 4 5void setup() { 6 pinMode(buzzer, OUTPUT); 7 Serial.begin(115200); 8} 9 10void loop() { 11 while (Serial.available()) { 12 char c = Serial.read(); 13 14 if (c == '\n') { 15 process(cmd); 16 cmd = ""; 17 } else if (c != '\r') { 18 cmd += c; 19 } 20 } 21} 22 23void process(String s) { 24 25 if (s.length() == 0) return; 26 27 if (s[0] == 'd') { 28 int ms = s.substring(1).toInt(); 29 delay(ms); 30 return; 31 } 32 33 int freq = s.toInt(); 34 35 if (freq <= 0) 36 noTone(buzzer); 37 else 38 tone(buzzer, freq); 39}[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.