Website Logo. Upload to /source/logo.png ; disable in /source/_includes/logo.html

Hacker School Log

Laura Skelton | Summer 2014 Batch

Hacker School Day 2: Arduino and Mesh Networking

I had such a fun day! In the morning I learned how to use Arduino to control Neopixel RGB LED lights from Adafruit. It was so fast to get going with this, and the code was easy to tweak to change the patterns the lights would display.

adafruit neopixels

We wrote some code a little later that cycled through a rainbow with alternating pixels flashing opposite colors off and on.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      if (i%2==0) {
          if ((j/10) %2==0) {
            strip.setPixelColor(i, Wheel((255-i-j) & 255));
          } else {
            strip.setPixelColor(i,0,0,0);
          }
      } else {
        if ((j/10) %2!=0) {
             strip.setPixelColor(i, Wheel((i+j) & 255));
          } else {
            strip.setPixelColor(i,0,0,0);
          }
      }
    }
    strip.show();
    delay(wait);
  }
}

Wheel is a neat little function in the Adafruit Neopixel code that converts a value from 0 to 255 to an RGB color value.

1
2
3
4
5
6
7
8
9
10
11
12
13
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

I’m so excited to learn more about hardware and connecting apps to display patterns with the lights.

I spent some time brainstorming about Mesh Networking with a group. We want to create our own implementation of ICMP (Internet Control Message Protocol) over Bluetooth LE, using iBeacons as a sort of push notification to alert nearby devices that messages are available, and broadcasting messages through the nodes of the network to get to the intended user.

We’re planning to link the mesh network up with a hardware project using the programmable RGB LED lights from Adafruit to represent the users of the network. I thought it would be cool to make a sort of giant firefly jar with light-dots flying around inside, with one dot representing each user-node of the mesh network. The ObjC iOS app would allow users to join the network and then set their dot’s color, which would be reflected in the physical firefly jar.

We found a source for an affordable Bluetooth LE adapter for the Arduino and mapped out a plan for how to design the network on the whiteboard. Excited to give it a go tomorrow!