trouble blinking an led
Posted: 08 Aug 2012 05:00
I've got a nice little function attached to an LED I stick in the corner of every screen to keep an eye on the battery. It works well, but i'd like it to blink when it gets under 10%. I thought I could just set a sin on the light attribute, but it doesn't seem to be working. Any suggestions?
Code: Select all
//note: battery only seems to update at 5% intervals.
//green if above 50%
if(battery<=1 && battery>=0.49){
setattribute(BatteryIndicator,'color',RGB(0,1,0));
}
//yellow if between 50% and 20%
if(battery<=0.5 && battery>=0.21){
setattribute(BatteryIndicator,'color',RGB(1,1,0));
}
//red if 20% or less
if(battery<=0.2){
setattribute(BatteryIndicator,'color',RGB(1,0,0));
}
//pulse is 10% or less
if(battery<=0.1){
setattribute(BatteryIndicator,'light',sin(time*10)*2);
}