Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/* cible : Arduino Nano chip Bluetooth HC05 led rouge (ou autre) bouton résistance 1 kOhm */ #include
#include
// Mapping Arduino Digital ports to Bluetooth Serial #define rxPin A4 #define txPin A5 #define baudrateBT 38400 #define ledPin 6 #define buttonPin 2 bool bLed, bBTLed; long unsigned int oldMillis, newMillis; const unsigned int tempo = 500; String msg; SoftwareSerial hc05(rxPin, txPin); String readhc05_Serial(); void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT_PULLUP); Serial.begin(9600); oldMillis = millis(); bLed = bBTLed = false; digitalWrite(ledPin, bLed); hc05.begin(baudrateBT); } void loop() { String msg = ""; newMillis = millis(); // debug //Serial.println("in loop(), newMillis " + String(newMillis) + ", bLed: " + String(bLed) + " bBTLed: " + String(bBTLed)); //delay(500); if (( !digitalRead(buttonPin) && newMillis > (oldMillis + tempo)) || (bBTLed != bLed)) { oldMillis = newMillis; bBTLed = bLed = !bLed; digitalWrite(ledPin, bLed); hc05.println(bBTLed); // debug //Serial.println("in if(), bLed: " + String(bLed) + " bBTLed: " + String(bBTLed)); //delay(500); } while (hc05.available() > 0) { int inChar = hc05.read(); if (isDigit(inChar)) { // convert the incoming byte to a char and add it to the string: msg += (char)inChar; bBTLed = msg.toInt(); } } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)