Lab_interaccio/2012/Marcelli/Cap/sd21_test/sd21_test.ino

49 lines
1.3 KiB
Arduino
Raw Normal View History

2025-02-25 21:29:42 +01:00
/*******************************
* Arduino example for DS21 *
* *
* By James Henderson, 2012 *
*******************************/
#include <Wire.h>
#define ADDRESS 0x61 // The address of the SD21
#define SERVO 0x3F // Address of first servo
int count = 0;
void setup(){
Wire.begin();
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
Serial.begin(9600);
Serial.print("Hola que tal!");
}
void loop(){
Wire.beginTransmission(ADDRESS);
Wire.write(SERVO);
Wire.write(235); // Send a value of 255 to servo 1
Wire.endTransmission();
delay(500);
Wire.beginTransmission(ADDRESS);
Wire.write(SERVO);
Wire.write(128);
Wire.endTransmission();
delay(500);
Wire.beginTransmission(ADDRESS);
Wire.write(SERVO);
Wire.write((byte)0); // Values of 0 being sent using writ have to be masked as a byte to stop them being misinterperted as NULL this is a bug with arduino 1
Wire.endTransmission();
delay(500);
Wire.beginTransmission(ADDRESS);
Wire.write(SERVO);
Wire.write(128); // send a value of 128 to servo 1
Wire.endTransmission();
delay(500);
Serial.print("Hola que tal!");
Serial.println(count++);
}