Created
October 2, 2013 18:11
-
-
Save h4ck4life/6798030 to your computer and use it in GitHub Desktop.
Arduino Uno R3 temperature sensor + buzzer sample code. Read more here:
http://alif.my/2013/10/project-2-temperature-sensor-buzzer/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float temp; | |
int tempPin = 0; | |
int buzzer=8; //Connect the buzz positive Pin to Digital Pin 8 | |
void setup() | |
{ | |
pinMode(buzzer,OUTPUT); //Set Pin Mode as output | |
Serial.begin(9600); | |
beep(500); | |
} | |
void loop() | |
{ | |
//digitalWrite(buzzer,LOW); | |
temp = analogRead(tempPin); | |
temp = temp * 0.48828125; | |
if(temp > 35) { beep(50); beep(50); } | |
Serial.print("TEMPRATURE = "); | |
Serial.print(temp); | |
Serial.print(" Celcius"); | |
Serial.println(); | |
delay(1000); | |
} | |
void beep(unsigned char delayms){ | |
digitalWrite(buzzer,HIGH); | |
delay(delayms); // wait for a delayms ms | |
digitalWrite(buzzer,LOW); | |
delay(delayms); // wait for a delayms ms | |
} |
How can i make this code interact with Matlab? I know I can create a GUI but i am not sure what is the KEY word or code to make this happen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sir i have this code and working properly but now i want add buzzer to alert if temperature increase
suppose if (temperature > 50) then buzzer beep
please help me
#include<LiquidCrystal.h>
LiquidCrystal lcd(2,4,7,8,9,10);
const int Sensor = A0;
byte degree_symbol[8] =
{
0b00111,
0b00101,
0b00111,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
void setup()
{
pinMode(Sensor, INPUT);
lcd.begin(16,2);
lcd.createChar(1, degree_symbol);
lcd.setCursor(0,0);
lcd.print(" Digital ");
lcd.setCursor(0,1);
lcd.print(" Thermometer ");
delay(4000);
lcd.clear();
}
void loop()
{
}