3,7 → 3,7 |
#include <Wire.h> |
|
#define light0 0x44 // A0 = L (I2C light0) |
#define light1 0x45 // A0 = H (I2C light1) |
#define light1 0x45 // A0 = H (I2C light0) |
|
#define LAMP1 13 // Callibration Lamp 1 |
#define LAMP2 6 // Callibration Lamp 2 |
22,11 → 22,10 |
Stepper myStepper(steps, M1,M2,M3,M4); |
|
// DS18S20 Temperature chip |
OneWire ds(5); // 1-Wire pin |
OneWire ds(5); // 1-Wire |
byte addr[8]; // Addres |
boolean sense; |
|
byte addr[8]; // 1-Wire Address |
boolean sense; // Sense of revolution |
|
void setup() |
{ |
sense=true; |
40,17 → 39,17 |
// initialize the serial port: |
Serial.begin(9600); |
|
Wire.begin(); // join i2c bus |
Wire.begin(); // join i2c bus (light0 optional for master) |
} |
|
|
void loop() |
{ |
byte i,n; // for fors |
byte present = 0; // for 1-Wire |
byte data[12]; // data from temperature |
byte inByte; // RS232 data |
int dd=0; // data from light |
byte i,n; |
byte present = 0; |
byte data[12]; |
byte inByte; |
int dd=0; |
|
digitalWrite(LAMP1, HIGH); // All outputs OFF |
digitalWrite(LAMP2, HIGH); |
66,7 → 65,7 |
{ |
// get incoming byte: |
inByte = Serial.read(); |
Serial.print("Incoming char: "); |
Serial.print("Prijat znak: "); |
Serial.print( inByte, HEX); |
Serial.println(); |
} |
74,7 → 73,7 |
//--------------------------------------------------------- Motor |
if (sense) |
{ |
// one revolution in one direction |
// step one revolution in one direction: |
Serial.println("clockwise"); |
myStepper.setSpeed(sspeed/2); |
myStepper.step(30); |
90,7 → 89,7 |
} |
else |
{ |
// one revolution in the other direction: |
// step one revolution in the other direction: |
Serial.println("counterclockwise"); |
myStepper.setSpeed(sspeed/2); |
myStepper.step(-30); |
111,7 → 110,7 |
ds.reset_search(); |
for(n=0;n<2;n++) |
{ |
if ( !ds.search(addr)) // search for next thermometer |
if ( !ds.search(addr)) |
{ |
continue; |
} |
156,7 → 155,7 |
Serial.print("Light0: COMMAND="); |
// Setup device |
Wire.beginTransmission(light0); |
Wire.send(0x00); // command register |
Wire.send(0x00); // sends light0 |
Wire.send(0b11000001); // setup (eye light sensing; measurement range 2 [4000 lx]) |
Wire.endTransmission(); // stop transmitting |
|
203,7 → 202,7 |
Serial.print("Light1: COMMAND="); |
// Setup device |
Wire.beginTransmission(light1); |
Wire.send(0x00); // command register |
Wire.send(0x00); // sends light0 |
Wire.send(0b11000001); // setup (eye light sensing; measurement range 2 [4000 lx]) |
Wire.endTransmission(); // stop transmitting |
|