Projet

Général

Profil

Feature #13387 » wifi_bot_master.ino

Outillage master I²C - Anonyme, 10/11/2021 14:13

 
#include <Wire.h>

void setup()
{
Wire.begin(0x50); // join i2c bus (address optional for master)
pinMode (12,OUTPUT);
Serial.begin(9600);
Serial.println("x= \n");
}
byte x='a';

void loop()
{
digitalWrite(12,HIGH); //begining program visual identification
Wire.beginTransmission(0x50); // transmit to device #0x50
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting

Serial.println(x); // allows to see the value of x on serial port
Serial.println("\n");

x++;

if (x=='h') // resets x
{
x='a';
}
delay(500);
digitalWrite(12,LOW); //program ends
delay (500);

}
(4-4/4)