Escolar Documentos
Profissional Documentos
Cultura Documentos
inMsec =
ultrasonic.convert(microse
c, Ultrasonic::IN);
Serial.print("MS: ");
Serial.print(microsec);
Serial.print(", CM: ");
Serial.print(cmMsec);
Serial.print(", IN: ");
Serial.println(inMsec);
delay(1000);
}
ultrasoundDuration *
0.017; // result in cm
}
/*
Program aplikasi pengukur suhu
Arduino LM35
Loki Lang
*/
#include <LiquidCrystal.h>
LiquidCrystal lang(12, 11, 5, 4, 3,
2);
int lm35 = A0;
int val = 0;
float temp;
void setup()
{
pinMode(A0, INPUT);
lang.begin(16, 2);
lang.setCursor(0, 0);
lang.print("Arduino");
lang.setCursor(0, 1);
lang.print("Pengukur Suhu");
delay(1000);
lang.clear();
}
void loop()
{
val = analogRead(lm35);
delay(100);
lang.setCursor(0, 0);
lang.print("Suhu celsius:");
lang.setCursor(0, 1);
temp = val * 5;
temp *= 100;
temp /= 1024;
lang.print(temp);
}
#include <Wire.h>
#include <LCD.h>
#include
<LiquidCrystal_I2C.h>
#define I2C_ADDR 0x3F //
<<----- Add your address
here. Find it from I2C
Scanner
#define BACKLIGHT_PIN
3
#define En_pin
#define Rw_pin
#define Rs_pin
#define D4_pin
#define D5_pin
#define D6_pin
#define D7_pin
2
1
0
4
5
6
7
int n = 1;
LiquidCrystal_I2C
lcd(I2C_ADDR,En_pin,Rw_p
in,Rs_pin,D4_pin,D5_pin,D6
_pin,D7_pin);
void setup()
{
lcd.begin (16,2); // <<----My LCD was 16x2
// Switch on the backlight
lcd.setBacklightPin(BACKLI
GHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home
lcd.print("SainSmartI2C16x2"
);
}
void loop()
{
// Backlight on/off every 3
seconds
lcd.setCursor (0,1);
// go
to start of 2nd line
lcd.print(n++,DEC);
lcd.setBacklight(LOW);
//
Backlight off
delay(3000);
lcd.setBacklight(HIGH); //
Backlight on
delay(3000);
}
Reset
/*External Reset Button
Circuit:
-One side of Push button
attached to RESET pin, and
to 5 volts through a 10K
resistor
-Other side connected to
one of the GND pins
Created MAY 2014
By Michael James
http://opensourcehardwareg
roup.com
This code is in the public
domain
*/
void setup(){
//begin Serial
Communications
Serial.begin(9600);
}//close setup
void loop(){
//capture the time the
board has been running
int time =
millis()/1000;
//print the time from
last reset
Serial.print("I was
reset ");
Serial.print(time);
Serial.println(" seconds
ago.");
Serial.println("Will you
stop Dave. I am afraid.");
delay(1000);
}//close loop
* +5 V
I/O Pin
*|
exclusive.
*\
*/
* \ 10K
/*
*/
*\
Read_Two_Switches_On_One_
*|
Pin
*/
*|
* digital pin
________+_____________/\/\/\
____________ ground
*|
*/
analog pin
*|
*|
the
* _____
* ___ ground
*_
is turned on,
*/
HIGH.
#define
schematic )
void setup()
Serial.begin(9600);
1 must be pushed
sw1 = 1;
position
void loop()
sw2 = 0;
sw2 = 0;
digitalWrite(swPin, LOW); //
Serial.print(sw1);
are off
stateA = digitalRead(swPin);
sw1 = 0;
Serial.println(sw2);
digitalWrite(swPin, HIGH); //
sw2 = 1;
delay(100);
stateB = digitalRead(swPin);
LOW