Color Define:
- Black
- Blue
- Green
- Yellow
- Red
- White
用TouchSensor來操控ColorSensor的燈光顏色,每按一下就換一種燈光顏色
Example:
task main(){
int Light=0;
SetSensorTouch(S2);
while(true){
if(Sensor(S2)==1){
Light++;
Wait(300);
}
switch(Light){
case 1:
SetSensorColorRed(S3);
break;
case 2:
SetSensorColorGreen(S3);
break;
case 3:
SetSensorColorBlue(S3);
break;
case 4:
SetSensorColorFull(S3);
Light=0;
break;
}
NumOut(20, LCD_LINE3, Sensor(S3)) //讀取ColorSensor的數值
NumOut(20, LCD_LINE3, Sensor(S3)) //讀取ColorSensor的數值
}
}
沒有留言:
張貼留言