mbed在途中的時候,腦筋壞掉買了Arduino Nano...
我還以為會是第二個MADE IN ITALY
隨便焊焊,用Blink踹一下...
/*
* SHT-15 - 4
*/
#include <SHT1x.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd( 7, 8, 9, 10, 11, 12 );
SHT1x sht1x( 6, 5 );
void setup() {
lcd.begin( 16, 2 );
lcd.print( "SHT-15 - 4" );
Serial.begin( 9600 );
}
String getWeather() {
float temp_c, temp_f, humidity;
String result = "";
temp_c = sht1x.readTemperatureC();
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
result.concat( (long) temp_c );
result += "C,";
result.concat( (long) temp_f );
result += "F,";
result.concat( (long) humidity );
result += "%";
return result;
}
void loop() {
lcd.setCursor( 0, 1 );
lcd.print( getWeather() );
Serial.println( "Running..." );
delay( 1000 );
}
#include <SD.h>
#include <SHT1x.h>
/*
* SHT 15 - 3
*/
#define DataPin 6 // DATA
#define ClockPin 5 // SCK
#define CSPIN 10 // SD CS pin
SHT1x sht1x( DataPin, ClockPin );
File myLogFile;
void setup() {
Serial.begin( 9600 );
Serial.print( "Initializing SD card..." );
pinMode( 10, OUTPUT );
if( !SD.begin( CSPIN ) ) {
Serial.println( "initialization faild!" );
return;
}
Serial.println( "initialization done." );
}
void loop() {
float temp_c, temp_f, humidity;
String log_msg = "";
temp_c = sht1x.readTemperatureC();
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
log_msg.concat( (long) temp_c );
log_msg += ",";
log_msg.concat( (long) temp_f );
log_msg += ",";
log_msg.concat( (long) humidity );
myLogFile = SD.open( "sht15.txt", FILE_WRITE );
if( myLogFile ) {
Serial.println( "Writing..." );
myLogFile.println( log_msg );
myLogFile.close();
Serial.println( log_msg );
Serial.println( "done." );
} else {
Serial.println( "error opening sht15.txt" );
}
delay( 1000 );
}
#include/* * SHT 15 - 1 */ #define DataPin 11 // DATA #define ClockPin 12 // SCK SHT1x sht1x( DataPin, ClockPin ); void setup() { Serial.begin( 9600 ); } void loop() { float temp_c, temp_f, humidity; temp_c = sht1x.readTemperatureC(); temp_f = sht1x.readTemperatureF(); humidity = sht1x.readHumidity(); Serial.print( "Temperature: " ); Serial.print( temp_c, 2 ); Serial.print( "C / " ); Serial.print( temp_f, 2 ); Serial.print( "F. Humidity: " ); Serial.print( humidity ); Serial.println( "%" ); delay( 1000 ); }
/** * IRRemote 2 */ #include#include #define BtnPin 2 int buttonState = 0; // IRremote的IR發射器只能裝在pin 3 IRsend irsend; void setup() { pinMode( BtnPin, INPUT ); Serial.begin( 9600 ); } void loop() { buttonState = digitalRead( BtnPin ); if( buttonState == HIGH ) { Serial.println( "GoGoGo" ); irsend.sendNEC( 0x2FF00FF, 32 ); } }