Interfacing of Bluetooth with Arduino:
#include <SoftwareSerial.h>//
int led=13;
long previousMillis = 0;
long interval = 1000;
int ledState = LOW;
long Counter=0;
void setup() {
Serial.begin(9600);
Serial.println("Bluetooth Connected....");
pinMode(led,OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
Counter+=1;
Serial.println(Counter);
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
digitalWrite(ledpin, ledState);
}
}
0 comments:
Post a Comment
if you have any doubt please let me know