#include<LiquidCrystal.h> LiquidCrystal lcd(12,11,5,4,3,2); int ledPin = 13; // choose the pin for the LED int inputPin = 2; // choose the input pin (for PIR sensor) int pirState = LOW; // we start, assuming no motion detected int val = 0; // variable for reading the pin status void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare sensor as input digitalWrite(inputPin, HIGH); Serial.begin(9600); lcd.begin(16,2); lcd.print("Hello World."); } void loop(){ val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, HIGH); // turn LED ON if (pirState == LOW) { // we have just turned on Serial.println("Motion detected!"); lcd.setCursor(0,1); lcd.print("Welcome....."); // We only want to print on the output change, not state pirState = HIGH; } } else { digitalWrite(ledPin, LOW); // turn LED OFF if (pirState == HIGH){ // we have just turned of Serial.p...
Posts
Voltage with analog input
- Get link
- X
- Other Apps
int sensorValue = 0; void setup() { pinMode(A0, INPUT); pinMode(13, OUTPUT); Serial.begin(9600); int res=0.0049; } void loop() { // read the value from the sensor sensorValue = analogRead(A0); //0-1023 float volt=map(sensorValue,0,1023,0000,5000); Serial.print("Voltage ="); Serial.println(volt/1000); Serial.print("="); Serial.println(sensorValue); digitalWrite(13, HIGH); delay(sensorValue); // Wait for sensorValue millisecond(s) digitalWrite(13, LOW); //Serial.println(sensorValue*res); delay(sensorValue); // Wait for sensorValue millisecond(s) } voltage>5 vlot
GSM
- Get link
- X
- Other Apps
Two door and send SMS that door is open. void setup() { Serial.begin(9600); //Initialise serial to communicate with GSM Modem } void loop() { delay(10000); //Give enough time for GSM to register on Network SendSMS(); //Send one SMS while(1); //Wait forever } void SendSMS() { Serial.println("AT+CMGF=1"); //To send SMS in Text Mode delay(1000); Serial.println("AT+CMGS=\"+9198xxxxxxxx\"\r"); //Change to destination phone number delay(1000); Serial.println("Hello from GSM Modem!");//the content of the message delay(200); Serial.println((char)26); //the stopping character Ctrl+Z delay(1000); } Two door and send SMS that door is open. void setup() { Serial.begin(9600); //Initialise serial to communicate with GSM Modem pinMode(8,INPUT); digitalWrite(8,HIGH); pinMode(9,INPUT); digitalWrite(9,HIGH); } void loop() { delay(10000); //Give enough time for GSM to register on Network if(!digitalRead(8)) { SendSMS(0); while(!digitalRead(8)...
bluetooth with led
- Get link
- X
- Other Apps
/* Fade This example shows how to fade an LED on pin 9 using the analogWrite() function. The analogWrite() function uses PWM, so if you want to change the pin you're using, be sure to use another PWM capable pin. On most Arduino, the PWM pins are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11. */ //assume bt connected to 0,1 //0 to off //1 to on int brightness = 0; void setup() { pinMode(9, OUTPUT); Serial.begin(9600); } void loop() { if(Serial.available()) { int sdata=Serial.read(); if(sdata=='0') { digitalWrite(9,LOW); } if(sdata=='1') { digitalWrite(9,HIGH); } } /*for (brightness = 0; brightness <= 255; brightness += 5) { analogWrite(9, brightness); ...
Calc of serial input with display the output on lcd.
- Get link
- X
- Other Apps
#include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); /*void loop() { // print the number of seconds since reset: lcd.print(millis() / 1000); // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): }*/ int iB = 0; // for incoming serial data void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps lcd.begin(16, 2); lcd.print("hello, world!"); } void loop() { char sdata[10]; // send data only when you receive data: if (Serial.available()==5) { // read the incoming byte: int d = Serial.readBytesUntil('=',sdata, 5); //abo...
Make calc with serial Communication. Consider operation of 1 digit value only,Perform +,-,/,*(%,&,|,*,sq)(display on lcd, 7seg))
- Get link
- X
- Other Apps
Step1: Initializations/Calculations/Assumptions/Connections Define pattern in which you want to take the data operand(a) operand(b) operation(o) Step2: Circuit Only arduino and specify rx,tx pin Step3: code int iB = 0; // for incoming serial data void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps } void loop() { char sdata[10]; // send data only when you receive data: if (Serial.available()==3) { // read the incoming byte: int d = Serial.readBytesUntil('=',sdata, 3); //abo // say what you got: Serial.print("I received: "); ...
sum and average using readdatauntil()
- Get link
- X
- Other Apps
int iB = 0; // for incoming serial data void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps } void loop() { char sdata[10]; // send data only when you receive data: if (Serial.available()==2) { // read the incoming byte: int d = Serial.readBytesUntil('=',sdata, 10); // say what you got: Serial.print("I received: "); Serial.println(sdata[0], DEC); Serial.println(", "); Serial.println(sdata[1], DEC); int a,b,c; a=0...