here is my dilemma...FIRST - what i am trying to do:
I have 2 trinkets and a mega 1280 (i know the schematic says 2560...but it doesn't have my model) talking via I2C...i have the master trinket 5V take input from a button...when pressed it is supposed light the LED connected to it and send a "1" to the 2 slaves...when you let go it sends a "0"...the slave trinket 3.3V waits for message...when receiving a 1 it turns on the led...a 0 turns is off...the mega does the opposite...0 turns it on the led and 1 turns it off.
what i have got working:
Trinket to Trinket I2C is working fine...where my issue comes into play is when i add in the mega...so i tried just trinket to mega...still a no go...so is there something i am doing wrong on the mega side??? the trinkets and the 4 bit level shifter are brand new from adafruit...the mega i have had for a while and have used to talk to other megas...i have attached code and schematic.
I didn't know WIRE and TinyWire protocols were compatible. I thought the ATtiny85 could not read WIRE and the Mega could not
read TinyWire. If they can I would like to know because then I can do the same thing with my UNO and my ATtiny85's .
from what i read...they are both I2C...and the TinyWire can read and write other I2C components...so i don't see why it wouldn't...but when i add the mega in the mix... i locks the trinkets...so i have no clue what is going on...i seen a vid of someone who is doing it here
i did the schematic in Fritzing...it is easy to do there...and it doesn't matter which side the constant is on
int c = 3;
if (c == 3) {Serial.println("true");}else{Serial.println("false");}
if (3 == c) {Serial.println("true");}else{Serial.println("false");}
they will both return true...my issue happen only after connecting the mega...BUT...i got it to work...i took the code in the receiveEvent and put it in the loop...YAYAYAYAYAY
I'm having a hard time finding the difference between your original Mega code and the corrected one you just posted.
Can you label the part you added so it is easier to see ?
I'm such an idiot. I didn't realize that was you doing the video. I thought you were posting the link for me to look at to answer my question until I read your last post. Nice vid ! That came out good.
thanks...i wanted to make something more than the others...but i didn't want to take 15 mins to explain how to hook everything up...part 1 is mostly for people who know I2C...but need to know how to link 5v and 3.3v devices together...part 2 will re-explain the I2C for arduino's and teach you it for the trinkets
Check out this video I did of a Police Car LED simulator that I made from a Scargill Youtube I saw. It's an ATtiny85 and four leds
two red and two blue.
Look at your schematic.
Level shifter LV input 3 not connected , HV 3 connected
LV input 4 connected HV 4 not connected
How does that work ?
Also, you don't show any current limiting resistors for the leds . Why ? (should be 220 ohms)
Why are there no 4.7k pullup resistors on SDA & SCL ? That's a standard requirement. I2C backpacks and lcds have them built in but when you DIY you have to include them to keep the bus stable and biased correctly.
I forgot to ask, does it matter what clock frequency the ATtiny85 is set for in the boards.txt file ? (will 1 Mhz work ?)
I programmed the chips and wired up the circuit and it's not working . I can't even get the leds to toggle.
Can you repost the working code for all three ?
The attached files are the code I am running (UNO instead of Mega)
is perfectly valid, and is recommended practise by some experts. Possibly, the same experts who recommend ++i instead of i++, for no good reason in 99.9% of usages.
The ostensible reason for writing this way, is that if you write ( by mistake )
if ( 0 = c )
you will get a compilation error.
But if you write ( also by mistake )
if ( c = 0 )
then you won't get a compilation error, you will get a bug which sometimes may be very difficult to track down.