5. ANNEXES
Kilobot User Manual
33
5.
ANNEXES
5.1
Examples of source code
These examples of source code have different purposes described in their titles.
5.1.1 Transmits data to neighbors, and blinks led when the message is
received:
void
setup()
{
// Initialize message:
// The type is always NORMAL.
message.type = NORMAL;
// Some dummy data as an example.
message.data[0] = 0;
// It's important that the CRC is computed after the data has been set;
// otherwise it would be wrong and the message would be dropped by the
// receiver.
message.crc =
message_crc
(&message);
}
…
// Register the message_tx callback function.
kilo_message_tx = message_tx;
// Register the message_tx_success callback function.
kilo_message_tx_success = message_tx_success;
//check for message
if (new_message == 1)
{
new_message = 0;
set_color
(1,1,1);//turn RGB LED white
printf
(Mess0);//send first byte of received message over serial debug cable
printf
(Mess1);//send second byte of received message over serial debug cable
printf
(" ");
delay
(10);//wait 10 ms
set_color
(0,0,0);//turn RGB LED off
}
Summary of Contents for KILOBOT
Page 1: ...Kilobot User manual Version 2 0 JANUARY 2016 ...
Page 4: ......
Page 42: ......
Page 43: ......
Page 44: ...K Team S A Z I Plans Praz 1337 Vallorbe Switzerland ...