"0x1DEF" ?
I just googled it, I'm wrong! its 0x12BCD.
"0x1DEF" ?
I just googled it, I'm wrong! its 0x12BCD.
I don't really have any code, I have the idea in my head and I know how to execute it but I don't know the I2c bit.
This is correct! Do you know why/how is this correct?
Do you want to perform this Pot based experiment? If yes, do you have a Pot like the following:

Unfortunately no, I don't understand how it turns into 5 characters from 4.
Yes of course!
1. You know that we count from 0, 1, ..., 9; there are ten symbols here; so, it is called 10-base or decimal base. The meaning of 4660 in decimal base is:
= 4x103 + 6x102 + 6x101 + 0x100
= 4000 + 600 + 60 + 0 = 4660.
2. Computer counts from 0, 1; there are two symbols here; so, it is called 2-base or binary base. the meaning of 1010 in binary base is:
= 1x23 + 0x22 + 1x21 + 0x20
= 8 + 0 + 2 + 0
= 10 in decimal base
3. There is another counting style which we (human being) use as a matter of convenience using 16 symbols like 0, 1, ..., 9, A, B, ..., F. It is called 16-base or hexadecimal base. The meaning of ABCD is:
= Ax163 + Bx162 + Cx161 + Dx160
= 10x163 + 11x162 + 12x161 + 13x160
= 40960 + 2816 + 192 + 13
= 43961
Based on the above description of 10-base, 2-base and 16-base, perform small additions on paper and pencil, you will be alright!
Do you like to carry out the I2C experiment using Pot? if yes, place the Pot on bread board and connect Vcc-pin at 5V, GND-pin at GND-pin and UTPUT-pin with A3-pin of MEGA.
Yep, already did that!
Can you show the picture?
Do want codes now?
Unfortunately no, I don't know how to add a picture. And also I have it in a soldered circuit.
You want me to send the code?
Yes!
You have a error, this has to be 43981!
If I understand correctly, do you want me to send the code for reading and sending the pot values from the MEGA?
Yes!
Well, I tried to use old code but it's not working.
I'm really confused how this byte system works
Master:
#include<Wire.h>
#define slaveAddress 0x08 //0001000 (7-bit)
int y;
void setup()
{
Serial.begin(9600);
Wire.begin(slaveAddress);
Wire.onRequest(receiveEvent); //ISR declaration
}
void loop() {
Wire.onRequest(receiveEvent);
y = analogRead(A3);
}
void receiveEvent()
{
Wire.write(lowByte(y)); //sending 0x34 of y via I2C Bus
Wire.write(highByte(y)); //sending 0x12 of y
}
Slave:
#include<LiquidCrystal_I2C.h>
#include<Wire.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define slaveAddress 0x08 //0001000 (7-bit)
void setup()
{
Serial.begin(9600);
Wire.begin();
lcd.begin();
lcd.backlight();
lcd.setCursor(0, 0); //DPos (0-15), LPos (0-1)
lcd.print("Forum");
//--------------------
Wire.requestFrom(slaveAddress, 2); //requesting 2-byte data
byte lByte = Wire.read();
byte hByte = Wire.read();
int x = hByte<<8|lByte;
//--------------------
lcd.setCursor(0, 1); //cursor at bottom line and left most position
lcd.print(x, HEX);
}
I also tried some examples from Arduino but my code didn't want to compile because of this line:
Wire.onRequest(receiveEvent);
1. Who is the Master -- stm32? Yes/No.
2. Who is the Slave -- MEGA? Yes/No.
3. Is LCD connected with Slave? Yes/No.
4. Is Pot connected with Master? Yes/no.
1.NO, Mega
2.NO, stm32
3.YES
4.YES
Corrected MEGA Master Sketch of post #37.
#include<Wire.h>
#define slaveAddress 0x08 //0001000 (7-bit)
void setup()
{
Serial.begin(9600);
Wire.begin();
analogReference(DEFAULT);
}
void loop()
{
unsigned int y = analogRead(A3); //read pot value
Wire.beginTransmission(slaveAddress);
Wire.write(lowByte(y);
Wire.write(highByte(y));
Wire.endTransmissioon();
delay(1000);
}
Corrected stm32 Slave Sketch of post #37.
#include<LiquidCrystal_I2C.h>
#include<Wire.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define slaveAddress 0x08 //0001000 (7-bit)
void setup()
{
Serial.begin(9600);
Wire.begin(slaveAddress);
Wire.onReceive(receiveEvent); //ISR declaratin
lcd.begin();
lcd.backlight();
lcd.setCursor(0, 0); //DPos (0-15), LPos (0-1)
lcd.print("Forum");
//--------------------
}
void loop()
{
}
void receiveEnemt(int howMany)
{
byte lByte = Wire.read();
byte hByte = Wire.read();
int x = hByte<<8|lByte;
//--------------------
lcd.setCursor(0, 1); //cursor at bottom line and left most position
lcd.print(x, HEX);
}
Upload the above sketches into Master and Slave.
Slowly turn the Pot and check that the reading on LCD also changes.
this line has an error:
Wire.onReceive(receiveEvent);
error:
'class TwoWire' has no member named 'onReceive'