티스토리 뷰
- Arduino Source Code
- I2C Communication
- ONLY 'DEVICEADDRESS1_WRITE' is correct
#include <Wire.h>
#define DEVICEADDRESS1_WRITE 0x2F // 0x5C, 0x5E
#define DEVICEADDRESS1_READ 0x5E // 0x5D, 0x5F
#define DEVICEADDRESS2_WRITE 0x58
#define DEVICEADDRESS2_READ 0x59
#define INCREMENT_WIPER 0x04
#define DECREMENT_WIPER 0x08
#define WRITEVALUE 0x00
void setup(){
Wire.begin();
Serial.begin(9600);
Test02();
Serial.println("Test Started");
}
void loop(){
byte value1 = 0x00;
while(true){
if(value1 > 0xF1) break;
WriteValue(value1);
value1 += 1;
delay(1000);
}
}
void WriteValue(byte valueIn){
Wire.beginTransmission(DEVICEADDRESS1_WRITE);
Wire.write(WRITEVALUE);
Wire.write(valueIn);
Wire.endTransmission();
}
void ScanAddress(){
byte address1 = 0x11;
while(true){
address1 += 1;
if(address1>0xF1) return;
Serial.print("Address : ");
Serial.println(address1, HEX);
Wire.requestFrom(address1, 3);
while(Wire.available()){
char char1 = Wire.read();
Serial.print(char1);
Serial.print(", ");
}
Serial.println("-A");
delay(100);
WriteValue(address1);
delay(500);
}
}
void Test01(){
Wire.requestFrom(DEVICEADDRESS1_READ, 3);
while(Wire.available()){
char char1 = Wire.read();
Serial.print(char1);
Serial.print(", ");
}
Serial.println("-A");
delay(100);
Wire.requestFrom(DEVICEADDRESS2_READ, 3);
while(Wire.available()){
char char1 = Wire.read();
Serial.print(char1);
Serial.print(", ");
}
Serial.println("-B");
delay(500);
Test02();
delay(500);
}
void IncreaseWiper(byte addressIn){
Wire.beginTransmission(addressIn);
Wire.write(INCREMENT_WIPER);
Wire.endTransmission();
}
void DecreaseWiper(byte addressIn){
Wire.beginTransmission(addressIn);
Wire.write(DECREMENT_WIPER);
Wire.endTransmission();
}
void Test02(){
Wire.beginTransmission(DEVICEADDRESS1_WRITE);
Wire.write(INCREMENT_WIPER);
Wire.endTransmission();
Wire.beginTransmission(DEVICEADDRESS2_WRITE);
Wire.write(DECREMENT_WIPER);
Wire.endTransmission();
}
[Test Curcuit - Schematic]
반응형
'SWDesk > Firmware' 카테고리의 다른 글
아두이노 나노 ESP32 - GET Request 예제 (0) | 2023.12.27 |
---|---|
SK6812 + Arduino-UNO (0) | 2022.09.15 |
아두이노 SMS 전송 (0) | 2022.05.19 |
Control Code for 7-Segment (0) | 2022.02.25 |
ESP8266 APmode 테스트 (1) | 2022.02.12 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 절연형
- Innovations
- 전류
- Decorator
- 전압전류모니터링
- Innovations&Hurdles
- 티스토리챌린지
- Innovation&Hurdles
- badp
- Hurdles
- Video
- 아두이노
- image
- 전압
- 배프
- 심심풀이
- arduino
- 둎
- 오블완
- 허들
- 혁신과허들
- ServantClock
- bilient
- 혁신
- 치매
- 빌리언트
- 심심풀이치매방지기
- 치매방지
- BSC
- DYOV
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함