Blinking bats

A second slice of LED-based Halloween goodness.

Blinking bats from nikkipugh on Vimeo.

These bats will be part of my attire for later today, but they’re really quite pleasing just by themselves!

A really simple build using an Arduino-based Real Bare Bones Board, some cardboard, some insulation tape some wire and 14 LEDs.

Here’s the code:

/*
blinking bats
nikki pugh 30th October, 2010
Attribution-NonCommercial-ShareAlike Creative Commons
Powers LED eyes for a colony of bats, blinking them in a random sequence at random intervals
http://npugh.co.uk/blog/blinking_bats/

LED pairs with 330ohm resistors in series, connected between the output pins and ground.
*/

int colonySize = 7; // How many bats do you have?

//control pins for each bat

int bat1 = 2; // bat1
int bat2 = 3; // bat 2
int bat3 = 4; // bat 3
int bat4 = 5; // bat 4
int bat5 = 6; // bat 5
int bat6 = 7; // bat 6
int bat7 = 8; // bat 7
int bat8 = 9; // bat 8
int bat9 = 10; // bat 9
int bat10 = 11; // bat 10
int bat11 = 12; // bat 11

int gap = 3; // gap before selecting next bat to blink
int colony[] = {bat1, bat2, bat3, bat4, bat5, bat6, bat7, bat8, bat9, bat10, bat11}; // Put bat IDs into an array
int batSelect = 1; // your bat selection variable - used for selecting a bat ID from the above array
int blinker = bat1; // the bat selected to blink
int i = 0; // counter for start-up blinks

void setup() {

randomSeed (analogRead (0)); //read from the (unused) analogue pin to get a value to seed the "pseudo-random number generator"

pinMode(bat1, OUTPUT); // set pins to be outputs
pinMode(bat2, OUTPUT);
pinMode(bat3, OUTPUT);
pinMode(bat4, OUTPUT);
pinMode(bat5, OUTPUT);
pinMode(bat6, OUTPUT);
pinMode(bat7, OUTPUT);
pinMode(bat8, OUTPUT);
pinMode(bat9, OUTPUT);
pinMode(bat10, OUTPUT);
pinMode(bat11, OUTPUT);

}

void loop() {

for (i = 0; i< 3; i ++) { //blink all bats' eyes at start-up digitalWrite(bat1, HIGH); digitalWrite(bat2, HIGH); digitalWrite(bat3, HIGH); digitalWrite(bat4, HIGH); digitalWrite(bat5, HIGH); digitalWrite(bat6, HIGH); digitalWrite(bat7, HIGH); digitalWrite(bat8, HIGH); digitalWrite(bat9, HIGH); digitalWrite(bat10, HIGH); digitalWrite(bat11, HIGH); delay (200); digitalWrite(bat1, LOW); digitalWrite(bat2, LOW); digitalWrite(bat3, LOW); digitalWrite(bat4, LOW); digitalWrite(bat5, LOW); digitalWrite(bat6, LOW); digitalWrite(bat7, LOW); digitalWrite(bat8, LOW); digitalWrite(bat9, LOW); digitalWrite(bat10, LOW); digitalWrite(bat11, LOW); delay (200); } digitalWrite(bat1, HIGH); //all eyes back on again digitalWrite(bat2, HIGH); digitalWrite(bat3, HIGH); digitalWrite(bat4, HIGH); digitalWrite(bat5, HIGH); digitalWrite(bat6, HIGH); digitalWrite(bat7, HIGH); digitalWrite(bat8, HIGH); digitalWrite(bat9, HIGH); digitalWrite(bat10, HIGH); digitalWrite(bat11, HIGH); while (true){ // infinite loop gap = random(1, 5); //wait some seconds before selecting next bat delay(gap*1000); batSelect = random (0, colonySize-1); //select a bat at random blinker = colony[batSelect]; digitalWrite(blinker, LOW); //blink delay(200); digitalWrite(blinker, HIGH); } }

A bull in Balsall Heath

I’ve been threatening to use time over the Christmas holidays to get to grips with Scratch, a programming environment aimed at young people. I’ve been curious about it for a year or so and have recently had some conversations with people who have practical experience of using it in schools that has inspired me to actually get on and investigate it.

Coding blocks in Scratch

Coding blocks in Scratch

I’m thinking that to start off with I’m likely to apply it to animation-themed projects – you just don’t see briefs asking for people to come in and teach kids how to code! Shame that: beyond systematic approaches, applying mathematical concepts etc etc, I think there’s something particularly valuable in the process of debugging that can be applied to wider things. Fits in with my thoughts about protovation and creativity.

Anyway, as ever with these freestyle learning things, it can be a bit tricky to conjure up mini-projects to provide an impetus. Fortunately though I’ve had a huffing duck to work with and then an escaped bull went for a wander around Balsall Heath.

Balsall Heath, bull and the Shouty Lady

Balsall Heath, bull and the Shouty Lady

I lived in Balsall Heath last year, so I kind of got a bit distracted by the backgrounds and distilling some key landmarks into simple graphic form, rather than designing a game, as was the original intention. Still, there was a lot to be learned in just getting the background tiles to scroll as the bull works its way up Moseley/Alcester Road. [Addendum: This whole thing probably won’t mean anything to you if you don’t know the area. If that’s the case, here’s a link to the Google Street View to give you a toehold.]

Moseley baths

Moseley baths

After some wrangling as to whether I was going to make it a shoot-em-up in the style of the real-life story, I eventually decided that that wasn’t a route I wanted to go down (well, it is Christmas!) so the hazard comes in the form of the Shouty Lady.

One of my overall impressions of living in Balsall Heath was that there always seemed to be people shouting in the streets. Not increased-volume-so-my-mate-over-there-can-hear-me shouting, but full-on screechy argument shouting at the person stood right by them, or perhaps now walking on the other side of the road. After a few months I began to recognise that, more often than not, it was the same woman doing the shouting…

So, in the Balsall Bull ‘game’ the Shouty Lady will appear at random intervals and potentially scupper your overall aim of getting to the curry house.

Scratch isn’t set up for embedding per se, but I’ve put Balsall Bull on a separate page so you can have a play if you’d like to. If you don’t see it on the page, you’ll need to download and install Java to be able to run the applet thingy.

To play Balsall Bull, use the arrow keys to guide the bull along the road, click the green flag in the top right corner if it goes sqiffy and, above all else, beware the Shouty Lady.



Copyright and permissions:

General blog contents released under a Creative Commons by-nc-sa license. Artworks and other projects copyright Nicola Pugh 2003-2020, all rights reserved.
If in doubt, ask.
The theme used on this WordPress-powered site started off life as Modern Clix, by Rodrigo Galindez.

RSS Feed.