Rev 2088 Rev 2089
Line 10... Line 10...
10 #define LAMP1 13 // Callibration Lamp 1 10 #define LAMP1 13 // Callibration Lamp 1
11 #define LAMP2 6 // Callibration Lamp 2 11 #define LAMP2 6 // Callibration Lamp 2
12   12  
13 int lamps[] = {LAMP1, LAMP2}; 13 int lamps[] = {LAMP1, LAMP2};
14   14  
15 #define FW1 7 // FilterWheel 1 15 #define FW1 7 // [PD7 - red] Slit Wheel 1-st from light
16 #define FW2 8 // FilterWheel 1 16 #define FW2 8 // [PB0 - yellow] Grism Wheel 2-nd from light
17 #define FW3 3 // FilterWheel 1 17 #define FW3 3 // [PD3 - blue] Filter Wheel 3-rd from light
18   18  
19 int filters[] = {FW1, FW2, FW3}; 19 int filters[] = {FW1, FW2, FW3};
20   20  
21 int motors[] = {-1, 1}; 21 int motors[] = {-1, 1};
22   22  
23 const int steps = 200; //3200; // change this to fit the number of steps 23 const int steps = 3500; // change this to fit the number of steps
24 const int sspeed = 100; // stepper motor speed 24 const int sspeed = 10; // max. 15 // stepper motor speed
25   25  
26 // initialize the stepper library on pins 26 // initialize the stepper library on pins
27 #define M1 9 27 #define M1 9
28 #define M2 10 28 #define M2 10
29 #define M3 11 29 #define M3 11
Line 75... Line 75...
75 } 75 }
76 } 76 }
77   77  
78 void motor (int arg) 78 void motor (int arg)
79 { 79 {
80 myStepper.setSpeed(sspeed/2); 80 myStepper.setSpeed(1);
81 myStepper.step(arg * 30); 81 myStepper.step(arg * 10);
82 myStepper.setSpeed(sspeed); 82 myStepper.setSpeed(sspeed);
83 myStepper.step(arg * (steps-50)); 83 myStepper.step(arg * steps);
84 myStepper.setSpeed(sspeed/2); -  
85 myStepper.step(arg * 20); -  
86 delay(50); -  
87 digitalWrite(M1, LOW); 84 digitalWrite(M1, LOW);
88 digitalWrite(M2, LOW); 85 digitalWrite(M2, LOW);
89 digitalWrite(M3, LOW); 86 digitalWrite(M3, LOW);
90 digitalWrite(M4, LOW); 87 digitalWrite(M4, LOW);
91 } 88 }
Line 168... Line 165...
168 Serial.println(analogRead(A2)-512, DEC); 165 Serial.println(analogRead(A2)-512, DEC);
169 } 166 }
170   167  
171 void readSerialString () 168 void readSerialString ()
172 { 169 {
173 if(Serial.available()) 170 serInIndx=0;
-   171 do
174 { 172 {
175 while (Serial.available()) 173 while(Serial.available()==0);
176 { -  
177 serInString[serInIndx] = Serial.read(); 174 serInString[serInIndx] = Serial.read();
-   175 Serial.print(serInString[serInIndx]);
178 serInIndx++; 176 serInIndx++;
-   177 } while ((serInString[serInIndx-1]!='\n')&&(serInString[serInIndx-1]!='.'));
179 } 178 Serial.print("\r\n=");
180 } -  
181 } 179 }
182   180  
183 void loop() 181 void loop()
184 { 182 {
185 readSerialString(); 183 readSerialString();
Line 192... Line 190...
192 { 190 {
193 case '?': 191 case '?':
194 Serial.println ("Device queries:"); 192 Serial.println ("Device queries:");
195 Serial.println (" l[0,1] light in luxes"); 193 Serial.println (" l[0,1] light in luxes");
196 Serial.println (" t[0,1] temperature in Celsius degrees"); 194 Serial.println (" t[0,1] temperature in Celsius degrees");
197 Serial.println (" F[0,1][0|1] switch filter wheel on (1) or off (0)"); 195 Serial.println (" F[0,1,2][0|1|?] switch filter wheel on (1) or off (0)");
198 Serial.println (" F[0,1]? check state of filter wheel"); 196 Serial.println (" F[0,1,2]? check state of filter wheel");
199 Serial.println (" L[0,1][0|1] switch calibration lamp on (1) or off (0)"); 197 Serial.println (" L[0,1][0|1] switch calibration lamp on (1) or off (0)");
200 Serial.println (" L[0,1]? check state of calibration lamp"); 198 Serial.println (" L[0,1]? check state of calibration lamp");
201 Serial.println (" M[0|1] motor rotation clockwise (1) or counterclockwise (0)"); 199 Serial.println (" M[0|1] motor rotation clockwise (1) or counterclockwise (0)");
202 break; 200 break;
203 case 't': 201 case 't':
Line 232... Line 230...
232 motor (motors[in1]); 230 motor (motors[in1]);
233 break; 231 break;
234 } 232 }
235 for (serInIndx = 100; serInIndx > 0; serInIndx--) 233 for (serInIndx = 100; serInIndx > 0; serInIndx--)
236 serInString[serInIndx] = ' '; 234 serInString[serInIndx] = ' ';
237 -  
238 Serial.flush (); -  
239 } 235 }
240 236
241 delay(100); 237 delay(100);
242 } 238 }
243   239