Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2025:mdinica:alin_ioan.alexandru [2025/05/28 00:12]
alin_ioan.alexandru [Rezultate Obţinute]
pm:prj2025:mdinica:alin_ioan.alexandru [2025/05/28 13:27] (current)
alin_ioan.alexandru [Software Design]
Line 161: Line 161:
   return digitalRead(sigPin);​   return digitalRead(sigPin);​
 } }
 +
 +</​code>​
 +
 +Timer:
 +
 +<code cpp>
 +
 +volatile int timeRemaining = 0; // Init when game starts
 +volatile bool updateLCD = false;
 +
 +void tick() {
 +  if (timeRemaining > 0) {
 +    timeRemaining--;​
 +    updateLCD = true;
 +  }
 +}
 +
 +void startTimer(int secunde) {
 +  timeRemaining = secunde;
 +  timerTicker.attach(1.0,​ tick);
 +}
 +
 +void stopTimer() {
 +  timerTicker.detach();​
 +  timeRemaining = 0;
 +  updateLCD = true;
 +}
 +
 +</​code>​
 +
 +Comunicare prin bluetooth:
 +
 +<code cpp>
 +
 +if (SerialBT.available()) {
 +    String mesaj = SerialBT.readStringUntil('​\n'​);​
 +    mesaj.trim();​
 +    mesaj.toLowerCase();​
 +
 +    if (mesaj == "​start"​) {
 +      startTimer(5 * 60);  // 5 minute
 +      SerialBT.println("​Timer pornit"​);​
 +    } else if (mesaj == "​reset"​) {
 +      stopTimer();​
 +      SerialBT.println("​Timer oprit/​resetat"​);​
 +    } else {
 +      SerialBT.println("​Comanda necunoscuta"​);​
 +    }
 +  }
  
 </​code>​ </​code>​
pm/prj2025/mdinica/alin_ioan.alexandru.1748380333.txt.gz · Last modified: 2025/05/28 00:12 by alin_ioan.alexandru
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0