No changes between revisions
/Designs/Spectrograph/SW/lamp/lamp.ino |
---|
1,11 → 1,7 |
// Lamps controller |
#define VERSION "$Revision$" |
#include <OneWire.h> |
#include <EEPROM.h> |
#define LAG 400 // dellay in ms between lamp relay switching |
// Triacs |
13,7 → 9,7 |
int t2 = 3; // PD3 - relay for switching between lamps |
int t3 = 4; // PD4 - halogen lamp |
int t4 = 5; // PD5 - focuser |
int t5 = 6; // PD6 - COLORES |
int t5 = 6; // PD6 |
int t6 = 7; // PD7 |
int t7 = 8; // PB0 |
int t8 = 9; // PB1 |
27,15 → 23,8 |
char deleni16[16]={'0','1','1','2','3','3','4','4','5','6','6','7','7','8','9','9'}; |
void info () // Print an information string |
int temperature () |
{ |
Serial.print("Lamps Controller "); |
Serial.println(VERSION); |
Serial.println("Commands: abcdefghABCDEFGHiS"); |
} |
int temperature () // Read temperature from Dallas |
{ |
int i, temp; |
byte data[12]; |
66,32 → 55,6 |
return temp; |
} |
void pstatus() // Print status to serial line |
{ |
int t; // Temperature |
t=temperature(); // Read temperature |
Serial.print (t >> 4); |
Serial.print ("."); |
Serial.print (deleni16[t & 0xf]); |
Serial.print (' '); |
for (n=1;n<=8;n++) |
{ |
if(digitalRead(n+1)) |
{ |
Serial.print('t'); |
} |
else |
{ |
Serial.print('T'); |
} |
Serial.print(n, DEC); |
Serial.print(' '); |
} |
Serial.println(); |
} |
// the setup routine runs once when you press reset: |
void setup() |
{ |
129,14 → 92,7 |
return; |
} |
for (n=1;n<=8;n++) |
{ |
digitalWrite(n+1,EEPROM.read(n)); // Read saved states from EEPROM |
} |
Serial.println("Hmmm...."); |
info(); |
pstatus(); |
} |
// the loop routine runs over and over again forever: |
143,6 → 99,7 |
void loop() |
{ |
byte inByte; // Character from serial line |
int t; // Temperature |
if (Serial.available() > 0) // wait for a char |
{ |
189,17 → 146,6 |
digitalWrite(t2, HIGH); |
state = 'b'; |
break; |
case 'i': // Print Info |
info(); |
break; |
case 'S': // Save states to EEPROM |
for (n=1;n<=8;n++) |
{ |
EEPROM.write(n,digitalRead(n+1)); |
} |
break; |
} |
if ( (inByte >= 'c') and (inByte <= 'h')) // Switch OFF other triacs |
212,6 → 158,26 |
digitalWrite(inByte-'A'+2, LOW); |
} |
pstatus(); // Print states |
// Send status to serial line |
t=temperature(); // Read temperature |
Serial.print (t >> 4); |
Serial.print ("."); |
Serial.print (deleni16[t & 0xf]); |
Serial.print (' '); |
for (n=1;n<=8;n++) |
{ |
if(digitalRead(n+1)) |
{ |
Serial.print('t'); |
} |
else |
{ |
Serial.print('T'); |
} |
Serial.print(n, DEC); |
Serial.print(' '); |
} |
Serial.println(); |
} |
} |
Property changes: |
Deleted: svn:keywords |
-Revision |
\ No newline at end of property |