#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
const int colorR = 255;
const int colorG = 0;
const int colorB = 0;
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB);
// Print a message to the LCD.
lcd.print("hello, world!");
delay(1000);
}
void loop()
{
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
delay(100);
}
#include <math.h>
const int B = 4275; // B value of the thermistor
const int R0 = 100000; // R0 = 100k
const int pinTempSensor = A5; // Grove - Temperature Sensor connect to A5
void setup()
{
Serial.begin(9600);
}
void loop()
{
int a = analogRead(pinTempSensor);
float R = 1023.0/a-1.0;
R = R0*R;
// convert to temperature via datasheet
float temperature = 1.0/(log(R/R0)/B+1/298.15)-273.15;
Serial.print("temperature = ");
Serial.println(temperature);
delay(100);
}
#include <math.h>
const int B = 4275; // B value of the thermistor
const int R0 = 100000; // R0 = 100k
const int pinTempSensor = A1; // Grove - Temperature Sensor connect to A1
void setup()
{
pinMode(pinTempSensor, INPUT);
}
void loop()
{
int a = analogRead(pinTempSensor);
float R = 4095.0/a-1.0;
R = R0*R;
// convert to temperature via datasheet
float temperature = 1.0/(log(R/R0)/B+1/298.15)-273.15;
Serial.print("temperature = ");
Serial.println(temperature);
delay(100);
}
/*
Buzzer
The example use a buzzer to play melodies. It sends a square wave of the
appropriate frequency to the buzzer, generating the corresponding tone.
The circuit:
* Buzzer attached to pin39 (J14 plug on Grove Base BoosterPack)
* one side pin (either one) to ground
* the other side pin to VCC
* Note:
This example code is in the public domain.
http://www.seeedstudio.com/wiki/index.php?title=GROVE_-_Starter_Kit_v1.1b#Grove_-_Buzzer
*/
/* Macro Define */
//#define BUZZER_PIN 39 /* sig pin of the buzzer */
// Nefry BT用にPIN定義を変更する
// Nefry BT無印の場合: D2, A0, A2 (注:D0は使えません)
// Nefry BT R2の場合: D0, D2, D5, A1 (注:A0を使うときはA1を記載します。)
#define BUZZER_PIN D2
int length = 15; /* the number of notes */
char notes[] = "ccggaagffeeddc ";
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
int tempo = 300;
void setup()
{
/* set buzzer pin as output */
pinMode(BUZZER_PIN, OUTPUT);
}
void loop()
{
for(int i = 0; i < length; i++) {
if(notes[i] == ' ') {
delay(beats[i] * tempo);
} else {
playNote(notes[i], beats[i] * tempo);
}
delay(tempo / 2); /* delay between notes */
}
}
/* play tone */
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(BUZZER_PIN, HIGH);
delayMicroseconds(tone);
digitalWrite(BUZZER_PIN, LOW);
delayMicroseconds(tone);
}
}
void playNote(char note, int duration) {
char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };
// play the tone corresponding to the note name
for (int i = 0; i < 8; i++) {
if (names[i] == note) {
playTone(tones[i], duration);
}
}
}