Earlier, I enjoyed the basic operation of the Grove Beginner Kit for Arduino.
https://www.hackster.io/H0meMadeGarbage/grove-beginner-kit-for-arduino-75e7be
I enjoyed device-to-device communication using Grove Beginner Kit for Arduino.
Seeeduino LotusGrove Beginner Kit for Arduino includes a Seeeduino Lotus as a controller.
I referred to the following for how to set the bar for Arduino IDE.https://wiki.seeedstudio.com/Seeed_Arduino_Boards/
Device-to-device communication- Ring the buzzer with the button.
- Detect the sound with a microphone. Then, illuminate the LED
- The lighting is detected by the optical sensor. Then, characters appear on the display.
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
const int buttonPin = 6;
const int buzzer = 5;
const int mic = A2;
const int LED = 4;
const int Light = A6;
int state = 0;
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //Low spped I2C
void setup() {
pinMode(buttonPin, INPUT);
pinMode(LED, OUTPUT);
Serial.begin(115200);
digitalWrite(LED, LOW);
u8g2.begin();
u8g2.setFont(u8g2_font_logisoso54_tf); // choose a suitable font
u8g2.clearBuffer();
}
void loop() {
//button-buzzer
if(digitalRead(buttonPin)){
tone(buzzer, 262, 1000);
}
//mic-LED
if(analogRead(mic) > 500){
digitalWrite(LED, HIGH);
}else{
digitalWrite(LED, LOW);
}
Serial.println(analogRead(Light));
//Light-Display
if(analogRead(Light) > 500 && state == 0){
u8g2.drawStr(30,60,"ON"); // write something to the internal memory
u8g2.sendBuffer();
state = 1;
delay(1000);
}else if(analogRead(Light) < 400 && state == 1){
u8g2.clearBuffer();
u8g2.sendBuffer();
state = 0;
}
}
Refer to the following for how to use the OLED display module.https://wiki.seeedstudio.com/Grove-OLED-Display-0.96-SSD1315/
The library for the display used:https://github.com/olikraus/u8g2
Comments
Please log in or sign up to comment.