I know this might sound pretty silly, but since I couldn’t find anywhere else how to do it, and I had to spend quite a lot of time figuring it out myself, I decided to post it. So, if you need to interface a brighter LED on a tmote sky (or whatever needs a digital input), connect the ground of the LED to pin 9 of the 10-pin expansion header of the tmote, and the other cable to pin 3 of the 6-pin expansion header (which is GPIO port 2, refer to the tmote datasheet for more info). After that, you need to write a proper “driver” to set pin 2.3 of the msp430 (tmote’s CPU) to 1 or 0. You can use the following macros:
#define P23_OUT() P2DIR |= BV(3)
#define P23_IN() P2DIR &= ~BV(3)
#define P23_SEL() P2SEL &= ~BV(3)
#define P23_IS_1 (P2OUT & BV(3))
#define P23_WAIT_FOR_1() do{}while (!P23_IS_1)
#define P23_IS_0 (P2OUT & ~BV(3))
#define P23_WAIT_FOR_0() do{}while (!P23_IS_0)
#define P23_1() P2OUT |= BV(3)
#define P23_0() P2OUT &= ~BV(3)
For example, to make the led blink at intervals of 1 sec (this is contiki code, but apart from the timer it’s standard C):
P23_OUT();
P23_SEL();
while(1)
{
etimer_set(&mytimer, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&mytimer));
if(toggle==0)
{
printf("Changing 1\n");
toggle=1;
P23_1();
printf("It's one\n");
}
else
{
printf("Changing 0\n");
toggle=0;
P23_0();
printf("It's zero\n");
}
}