Author: Annie Kelly Do you ever wonder how our pets see, hear, smell, and experience the world differently than we do? While we can never know exactly what it is like to be our pets, but we can still explore what it would be like to have similar senses to our pets. Certain senses like smell and hearing are hard for us to experience like our pets do, because these senses go far beyond our own capabilities. However, our cats' and our dogs' color perception is more limited than our own, so we can use Augmented Reality to look at the world with slightly diminished capabilities --- letting people explore the world from the visual perspective of a dog or cat. We created DoggyVision and KittyVision filters for Snapchat to make this experience available for free! See the next section for how to get these filters on your phone and laptop today. DoggyVision and KittyVision...for Snapchat! An unfiltered photo of a painting (left), the same painting taken using the KittyVision Snapchat filter (right). DoggyVision and KittyVision are now available for free through Snapchat. If you are unfamiliar with Snapchat, it is a free photo-sharing app available for iOS and Android. One of Snapchat's main features is you can apply many different filters to your photographs and videos that you take through the app. If you have Snapchat, you can search for the filters DoggyVision and KittyVision through the app using the search bar, or visit these links on the device where you have installed Snapchat:
You can also try scanning the "Snapcodes" (i.e. Snapchat QR codes) below directly through the Snapchat camera, however this method does not seem to work for all users. For those who use Zoom, you can use Snapchat filters during your conference calls by downloading the Snap Camera app. From there, you can search for DoggyVision, KittyVision, and thousands of other filters. How is my vision different from my dog's or my cat's? Color Perception
The two charts above show the color spectrum for a non-visually impaired human (top), and the color spectrum for dogs and cats (bottom). The bottom chart is also similar to deuteranopia in humans (red-green color blindness). Visual Acuity Visual acuity refers to visual clarity. Near- and far-sightedness are both conditions related to weakened visual acuity in the eye. Humans have 4-8x better visual acuity than dogs and cats. You can think of this as dogs and cats having a more "blurry" view of the world, similar to how if a human is nearsighted, farther objects will look blurrier than normal. Brightness Discrimination Brightness discrimination is the ability to perceive different shades of a color. Dogs and cats have brightness discrimination that is about 2x worse than humans. This effectively means they see the world with slightly less contrast. Field of Vision Field of vision describes the observable area of our eyes. For humans, our field of view is about 180 degrees, meaning if you picture a sphere around a human, we can observe most of the front half of the sphere that we are facing. Cats have a wider field of vision than humans do at around 200 degrees. Dogs have an even wider field of vision at around 240 degrees. Having a wider field of vision typically means less visual overlap between the eyes, therefore cats and dogs have poorer depth perception than humans do despite having better peripheral vision. The shape of our corneas as well as the placement of our eyes on our heads affect field of vision, meaning that field of vision is also variable between breeds of cats and dogs. For example, pugs' eyes are situated more on the front of their face, whereas collies' eyes are placed further to the sides of the face. These visual effects are not currently replicated in the DoggyVision or KittyVision filters, but could be with the addition of external lenses over the camera. Differences between dog and cat vision Dogs have a wider field of view than cats. It is also believed that cat's have worse brightness discrimination than dogs, but better vision than dogs in low-light conditions. While there are some differences between dog vision and cat vision, it is beyond the hardware of most phones to replicate all of these differences. Therefore, the DoggyVision and KittyVision filters are relatively similar, with the contrast being a little lower on the KittyVision filter. Acknowledgements This work is supported by National Science Foundation award #1736051. References
On June 15th and 16th, Laboratory for Playful Computation (LPC) students Annie Kelly and Celeste Moreno traveled to Santa Fe to represent the LPC at an incredible event called the InterPlanetary Festival in Santa Fe, New Mexico. You can read more about the festival here. We hosted a booth at the Innovations and Ideas expo where visitors could create space and sci-fi themed postcards using a combination of craft materials and electronics. 120+ visitors of all ages hacked and crafted postcards with us. Some spent a couple minutes at our booth, and others came back multiple times in the same day to make more postcards. This was our setup at the beginning of the day. We had a variety of craft materials available to use from colored pencils to tissue paper to styrofoam balls to laser cut space-themed stamps. We had several examples of postcards on display as well. Some were made to light up using paper circuit materials like copper tape and LED lights, some were just paper, and the postcards in the foreground of this image could be turned on and off by shaking a micro:bit (more information on that coming soon). Shortly after the exhibiting hours started, this pretty display and many of the examples were put away to make room for all of the visitors that wanted to make a light up postcard. Postcards were made nonstop from noon to 6pm and our well-organized crafting/hacking space turned into a beautifully chaotic creation space. (Friend of the lab and PhD student at CU Boulder Megan helped visitors make postcards on Day 1. Thanks Megan!) While visitors didn't have to make their postcards light up , nearly all of them wanted to. We chose to incorporate paper circuit making into this activity because it's a non-intimidating entry to learning about circuits and electricity that allows for creative expression. The abundance of crafting materials and creativity of our booth visitors led to some great postcards: Here's a look at a couple of my favorites. On the left: One of our visitors hacked one of our example circuits. She made a "brain" for the alien by cutting up a styrofoam ball and drawing on top of it. On the right: One visitor decided she wanted to make a postcard for her dad since father's day was the next day. Facilitation Tips: After making over 100 circuits with visitors we came up with some tips and tricks for facilitating paper circuits in a setting where you might have multiple people that you're helping at once who are all at different places in their construction process. Here's what the whole process looks like: Mary Yoder On April 13th I worked with several sophomore business students led by Aleah Hyvonen to organize and run an event for elementary and middle-school girls. The event was mainly centered around encouraging the girls to get excited about code and provide them with resources to improve their coding skills. The day was split into three parts; the first of which was team-building and get-to-know you games, where we were able to introduce ourselves and areas of study as well as introduce the girls to one another and pair them up for later activities. The second part was a coding session where the girls got to learn how to use and play around with BlockyTalky and Microbits. The third part of the event was guest speakers, during which Orit Peleg delivered a notable presentation on the connections between insect behavior and robotics programming and what integrating the two can achieve. In her presentation, Peleg covered several types of insect behavior, including swarms, and related these concepts to that of robotics, in particular swarms of tiny robots that have similar benefits to naturally-occurring swarms. The coding session was the heart of the event, so a lot of effort went into making it run smoothly. I worked with Aleah and several members of Society of Women Engineers's (SWE) Boulder chapter to plan several engaging yet not too difficult "coding challenges" using BlockyTalky. Using the submissions from SWE, as well as the help from several wonderful SWE volunteers we managed to set up 10 Microbit stations, each manned by two girls, and run the session fairly smoothly. There was wildly varying code experience among the participants, so the original design for a very straightforward session was soon altered. Certain girls had taken code in school, and were attempting to write scripts for their bits in Java rather than the default block module, others had never coded in their lives and found the blocks easy to use. One of the more fun demonstrations from the coding session was a simple video game prototype I had made in BlockyTalky and tasked the girls with replicating the code I had written and then adding to it to improve and expand the function. Overall, it was excellent to see the girls get into coding and work with materials and programs many of them were unfamiliar with. The positivity and resilience I observed in both the participating girls and the SWE volunteers captured the real spirit of the event, and the spirit of the Lab as well.
Will Temple A few months ago, our team began development on what will become the third iteration of our BlockyTalky program editor. It uses the Microsoft MakeCode editor (like the BBC micro:bit editor), also known as PXT, that provides creative programmers the ability to program the Raspberry Pi hardware using a familiar, blocks-based editor suitable for those with little to no programing experience. Currently, we support the GrovePi+ shield for Raspberry Pi 2 and later, but additional libraries (such as Internet messaging!) are forthcoming. Quick Demo The example program below shows the process of building a program that turns an LED on and off on an interval controlled by a knob. Higher values on the knob correspond to a longer interval. How It Works & Details for Developers The editor is hosted on the Raspberry Pi. When you save your program in the browser, the editor sends the code (what you see in the "JavaScript" tab in the editor) to the Raspberry Pi, which compiles and runs the program with TypeScript and NodeJs. Because BlockyTalky 3 programs run in Node, packages for our editor can leverage the wide variety of software libraries that are already available and packaged in NPM, such as the official GrovePi NodeJS software distribution, which we use to enable GrovePi support. Our full set of run-time support libraries provides the blocks that you are used to from micro:bit, so functions such as `loops.forever()` work as you would expect and run asynchronously. If you are interested in developing with us and working on BlockyTalky 3, or if you want to deploy your own BlockyTalky 3 editors, the code can be found on the following GitHub links:
Annie Kelly Me playing bass and controlling a light show in real-time using cardboard foot pedals to trigger different lighting effects that I programmed ahead of time. What? Why? Let me start off by telling you what I'm all about. I have a B.S. in Computer Science and also like to play bass guitar and make music in my spare time. Both of these interests are what led me to where I am today— wanting to create better computing technologies for artists and musicians to mess around with. Often times (not always of course) when you go to a venue the sound and the lighting are both being run by white dudes. You may have even heard the phrase "lighting guy" or "sound guy." There is no reason why these technologies and spaces need to be monopolized solely by tech-y white guy, but it has now become ingrained in our culture. In addition, there's no reason that these technologies can't be adapted to be more usable as DIY tools for the performers' themselves. I want to convince more people that they are capable of doing these kinds of things. By adapting and remixing some popular DIY maker technologies, I have built the first iteration of what I hope to be an accessible toolkit for programming light shows and controlling them with custom built tangible interfaces. The micro:bit is commonly discussed as a computer science educational tool for children and adolescents. It is less commonly discussed as a useful tool for adult artists and musicians, and even for seasoned programmers like myself. I love using it. The Raspberry Pi on the other hand has typically been touted as a low-cost computer alternative for everyday use, or a playground for hackers to create all sorts of cool projects. Developing software for the Pi is not a beginner-friendly activity— however in this project I will describe how the Pi can be easily equipped with software to make it a powerful tool for allowing people to interface professional level hardware and more beginner-friendly microcontrollers. In particular, I will focus on stage lighting production tools and hardware. Some important jargon I'm going to give you a brief overview on working with stage lighting. Most of the time, whether it's a fog machine, an RGB light, lasers, etc, these devices can be controlled by a standard called DMX512. There are a couple of ways to control DMX devices: you could use a console like what you would typically see in a venue (think a big interface with lots of sliders and buttons), but you can also use a DMX USB interface and computer software like I have been doing in this project — I'll just refer to both of these generally as controllers. The number of OUTs on a controller determines how many universes it can control. One universe can contain up to 512 channels, hence the name DMX512. Each device has a certain number of channels, and different channels correspond to different parameters of the device. For example, channel 4 on a light might be the master dimming setting. This information will come back later when I talk about the block-based programming API I made for this. System setup In the above diagram you can see that there are a few different components working together to make this all work. The micro:bit writes over serial to the Raspberry Pi, the Pi parses the serial data and wraps it into properly formatted DMX512 commands which are then sent to the Enttec OpenDMX USB interface, which in turn updates the two lighting fixtures. The software I wrote for the Pi relies on the Open Lighting Architecture Python API. The entire setup above cost about $200 (Raspberry Pi $40, micro:bit $12, DMX USB interface $70, Stage lights x2 $80). That's obviously not a trivial amount of money, however that is extremely low compared to the cost of some brand name, closed-source hardware, and also removes the cost of paying a lighting engineer to run the rig. For reference, Chauvet's, which is a popular brand for DJ equipment, consoles will set you back a few hundred bucks not including the amount you have to spend on lights as well. With this setup, the user (unless they want to dive deeper into the software on the Pi) only has to program the micro:bit in order to control the lighting. The micro:bit programming editor provides many high-level abstractions for controlling the lights, just as a standard console that you would find in a venue. In the next section I will show an example of how I made three cardboard foot switches that trigger different sequences that I programmed on the micro:bit. Making a light show The above image shows the three foot switches I made for this light show (for a tutorial on how to make a pressure activated foot switch for the micro:bit go here.). Each switch can each be activated by stepping on them. The left most switch triggers a pink/yellow chase pattern (connected to pin P0 on the micro:bit), the middle switch triggers the orange scene (connected to pin P1), the right switch triggers the blackout (connected to pin P2). By default the scene is green when I am not stepping on any of the switches. When I say scene I mean a static light setting, for example in a given scene one light might be pink, and the other might be yellow. Different patterns can then be made by combining scenes. A chase pattern is a sequential switching between scenes, and in this example my chase is just the two lights switching back and forth between being pink and yellow (you can see everything I am talking about in the video at the start of this post). Now that you know how the switches are connected to the micro:bit, let's look at the above code to see what's going on. When the program starts it first specifies that there are two lights in this setup and that each light has 8 channels. It then sets both lights' channel 3 to 255, which sets the lights master dim to full brightness. If you look inside the forever loop you will notice a series of if statements that check whether or not I am pressing down on any of the foot switches. If I am pressing down on switch 1 (pin P0) the program calls the chase function, if I press down on switch 2 (pin P1) the program calls the orange function, if I press down on switch 3 (pin P2) the program calls the blackout function, and if I am not pressing any of the switches the green function is called. Each of these functions is defined to the right. Let's look inside the green function. You can see a series of "update channel" calls being made. light1 update channel 4 to 0 light1 update channel 5 to 100 light1 update channel 6 to 0 light2 update channel 4 to 0 light2 update channel 5 to 100 light2 update channel 6 to 0 send dmx As I mentioned earlier, each of my lights has 8 channels. However in this example I am only using channels 3-6 on each light. This is because channel 3 corresponds to the master dimming setting, channel 4 is the red setting, channel 5 is the green setting, and channel 6 is the blue setting. These lights use what is called RGB to create a color and each one can be a value between 0-255. For example, if red is 255 and green and blue are both 0 — the light will be red. If we then change blue to be 255, the light will become purple because we are mixing red light with blue light (think back to art class about how color mixing works). So, with that knowledge we can now look at the code example I posted above for the green function and see that it is in fact setting both lights to be green and then calling "send dmx" to officially update the lights. Now you can look at the other functions and try to see if you can figure out what is going on. Remember, you can always watch the video again for help. Other thoughts, next steps As a bassist who doesn't typically use pedals when I play, it is easier for me to use my feet to control lighting as opposed to a guitarist who might have to be switching distortion on and off at the same time that she would want to change the lights. There are other ways we can imagine controlling the lights in real-time. There is the potential to use audio analysis to detect transitions in the songs, entirely pre-programmed light shows that are fully automated, or have a friend in the audience running the lights for her. The nice thing about using a microcontroller is that there are tons of possibilities that are left to the imagination.
Some of the next steps for this project will be further simplifying the API and providing a better way for users to keep track of which channels on each of their lights corresponds to what setting. In addition, I hope to further automate the software on the Pi so it is as simple as just powering everything on instead of having to ssh into the Pi and start the software manually. I am still learning a lot about DMX512 and practical lighting applications, so I'm sure things will change as I continue my research. Keep your eye out for some Raspberry Pi images available for download in the future. Thanks for reading! CLS Workshop: Tangible and Playful Connected LearningAnnie Kelly When we talk about tangible and playful learning, it is often discussed in the context of children. In this workshop I would like to discuss the application of these concepts for amateur and professional artists and musicians. This is part of a project we call Weird Code Club. We are focused on empowering indie artists to incorporate computing practices and interactive technologies into their live acts. We will be constructing and programming tangible interfaces that can scrub through a YouTube video. This is an example of VJing (Visual Jockeying) which is a common artistic practice used in live audiovisual performance. Author using a touch button to seek to a particular point in a music video. A few examples of constructed tangible controls: slide potentiometer (top left), potentiometer/knob (bottom left), pressure activated button (right). This post will describe the differences between the three and how to go about constructing and programming them using craft materials and a micro:bit. micro:bitThis tutorial will be using the micro:bit, if you are unfamiliar with the micro:bit please see their Getting Started page. This is not a micro:bit tutorial. In the programming examples you will notice the use of some serial blocks. This is because the micro:bit is sending information over the serial port to my laptop, which then is used to control the YouTube video. In order to interface with the YouTube scrubbing API you have to use the write line to serial block with the following strings: play (plays video) pause (pauses video) stop (stops video) seek:58 (seeks to 00:58 in video) rewind:30 (rewinds video by 30 seconds) fastforward:25 (fastforward video by 30 seconds) speed:2 (set playback rate to 2x the speed) id:mZxxhxjgnC0 (set the YouTube video using the id) volume:76 (sets volume to 76) mute:1 (mutes video) ButtonThis is an example of constructing a pressure activated button to seek to 00:58 in a YouTube video. The button itself is quite simple to construct and a brief step by step process can be found here. Basically, there are two pieces of foil: one is connected to power, and one is connected to a digital data pin. We the pieces of foil are not touching, the reading is 0. When the pieces of foil touch, the reading is 1. This allows us to use it as a button or a switch. The below example code demonstrates how to read the state of the button. When it is 1 (i.e. pressed) we seek to 00:58 in the video, otherwise when the button is 0 (i.e. released) we do nothing. However, you might want to use your button differently than this. For example you can program an event to occur when the button is released, or you can have an event occur repeatedly while the button is pressed down. In this program we are reading the value from digital pin 1, so make sure your button is attached to the same pin that is chosen in the code. SliderThis is an example of constructing a slide potentiometer that controls the playback rate of a YouTube video. Instead of foil like in the button example, here we are using graphite from a pencil as a conductor. This provides a nice level of resistance to get varying readings along the slide potentiometer. In the video below, as I move the green pin away from the red pin at the top, the voltage reading is lower. As I move the pin closer to the top, the voltage reading is higher. In the example code below note the use of the map function. This is reading the value of our slide potentiometer and transforming it into its corresponding video speed within a certain range. In other words, when the potentiometer is at its lowest point, the video playback will also be set to its lowest speed. KnobThis is an example of constructing a knob, or potentiometer, that controls the volume of a YouTube video. This works similarly to the last example with the slide potentiometer. Here we are again using graphite as a conductor, but we have the data pin attached to a piece of foil that we can rotate along a pivot. As it rotates the foil either moves closer or further from the power source, thus changes the voltage readings.
Annie Kelly
This tutorial will show you how to modify a pet toy to detect shake using the micro:bit.
Step 1: Preparing your supplies
1. Computer (laptop or desktop)
You will need to use a computer with internet access and a USB port to program the micro:bit.
2. Two micro:bits (2) and at least one microUSB cable (1)
You will need two micro:bits (~$12) and at least one USB cable to complete this tutorial. Many retailers sell starter kits such as this one.
3. Battery pack (at least 1)
You will need one battery for the micro:bit that goes inside of the toy. In this tutorial we are using a rechargeable Lithium Ion battery, but you can also use a AA or AAA battery holder.
4. Pet toy
A pet toy of your choosing, I would recommend a stuffed toy since it will be easiest to insert the micro:bit and battery.
5. Scissors and/or utility knife
These will be necessary for making an incision in the pet toy.
6. Glue, tape, sewing kit, etc.
This is for closing the incision on the pet toy.
Step 2: Programming your micro:bits
We will be using two micro:bits in this tutorial. One micro:bit will go inside of the toy and do the actual shake detection, and the other micro:bit will be the one that displays us information and/or does something when a shake is detected. In order to do this, we will be using the micro:bit radio features.
By the end of this tutorial you will have shake sensing code on the micro:bit inside of the toy that sends a message to the other micro:bit that displays "Hi!" on the LED screen when a shake is detected. Go to https://makecode.microbit.org/ to use the blocks based programming editor for the micro:bit. If you are unfamiliar with micro:bit programming you may want to visit the official Getting Started page.
Step 2.1: micro:bit sending code (for the micro:bit that goes inside the toy)
First let's write the code for the micro:bit going inside of the toy. Let's call this the SENDER micro:bit since it will be sending messages to the other micro:bit. I recommend labeling each of the micro:bits so you remember which code is on which one. Label this one SENDER, and the other micro:bit RECEIVER.
From the Basic block category select the on start block. The on start block is what runs one time when the micro:bit is turned on. Now let's look inside the Radio block category. Select the radio set group block and place it inside of the on start block. The radio set group chooses what channel the micro:bit's radio will communicate over. Imagine you had two walkie-talkies and you are trying to talk to your friend -- you have to be on the same channel as each other for it to work. This is the same concept. In this example I set my group to 5, but you can choose any number from 1-255 as long as you make sure to set your group to be the same value on both of your micro:bits! Now, let's open the Input block category. Select the on shake block. This block will be activated when the micro:bit detects that it has been shaken. Let's open the Radio block category again, but this time select the radio send number block and place it inside the on shake block. Now when you shake the micro:bit it will send a number over the radio. For this tutorial the number you send is arbitrary (it is 0 by default), but in more complicated examples you may want to send a specific number. Now our micro:bit toy code is complete! You can see the program below and download it there if you'd like. Once you've downloaded the code, upload it to the micro:bit we labeled as the SENDER. Step 2.2: micro:bit receiving code
Now let's program the second micro:bit that will be receiving messages from the micro:bit inside the toy.
Like we did in Step 2.1, go to the Basic block category and select the on start block. Now go to the Radio block category and select the radio set group block and place it inside of the on start block. Make sure you set the group number to be the same number that you used in the code from Step 2.1 otherwise this won't work! Now, go back to the Radio block category and select the on radio received receivedNumber block. This code will run whenever the micro:bit receives a number over the radio. If you recall, in step 2.1 we wrote a program to send a number whenever a shake is detected; this means that whenever a shake is detected on the micro:bit inside the toy, this on radio received code will be run. Go back to the Basic block category and select the show string "Hello!" block. You can change "Hello!" to whatever you like. I recommend keeping it short since it takes a while for the text to scroll across the micro:bit's screen. Now our micro:bit receiving code is complete! You can see the program below and download it there if you'd like. Once you've downloaded the code, upload it to the micro:bit we labeled as the RECEIVER. Step 3: Insert 1 micro:bit into the toy
In this step we'll take the micro:bit labeled "SENDER" and insert it inside the toy. Make an incision either using scissors or a knife on the toy. On mine the best place to do it was on the mouse's belly, on yours it might be different. Once I made the incision, a lot of stuffing started coming out. Instead of pulling it out I cut off the excess with some scissors so that I didn't accidentally remove too much. The toy I used in this tutorial already had a vibrating motor inside of it, so I carefully removed it. Once it looked like there was enough space for the micro:bit and battery I carefully inserted it (make sure you connect the battery first).
You might need to wiggle the micro:bit around to get it to fit nicely. You may want to glue, tape, or sew the toy back together, but I would recommend testing briefly before doing this.
Step 4: Test and play!
Make sure both micro:bits are powered on and then give the toy a good shake, you should see "Hi!" scroll across the LED screen on the other micro:bit.
Annie Kelly
This tutorial will show you how to build a switch that can be activated by pushing down on it with your hands, feet, pets' paws, etc.
Step 1: Preparing your supplies
This tutorial will be using a tiny programmable computer called the micro:bit and basic craft and electronics materials.
1. Computer (laptop or desktop)
You will need to use a computer with internet access and a USB port to program the micro:bit.
2. micro:bit and a microUSB cable
You will need a micro:bit (~$12) and USB cable to complete this tutorial. Many retailers sell starter kits such as this one.
3. Alligator clips
In this tutorial I simply use alligator clips to connect the servo to the micro:bit, but for a more finished project you may want to consider soldering the connections so that they are more secure.
4. Cardboard and scissors
In this tutorial we are building the switch out of cardboard.
5. Aluminum foil
This will be the main material necessary for detecting pressure on the switch.
6. Tape
Any tape is fine. Glue is also an acceptable substitute.
Step 2: Assemble the switch
We will be using 3 pieces of cardboard to create the pressure switch. The two larger pieces will go on the outsides, and the smaller piece will go in the center. This is so that when we push down on the switch the outsides of the two larger pieces will make contact. In this example the two larger pieces are 4 in x 5 in, and the smaller piece is 3.5 in x 3.5 in. Feel free to adjust these sizes to your liking.
Next we want to cover both of the larger pieces in aluminum foil (leave the smaller center piece alone, it will not work if you cover it in foil). We want the inner-facing sides of the pieces to be completely covered in foil. To do this, cut a piece of foil larger than the piece of cardboard and then tape the pieces over the back edge.
This is what the backs of the larger pieces should look like.
And this is what the other side of the large pieces look like. Now we are ready to put all the pieces together.
Tape the smaller piece onto the inside of one of the larger pieces. Then tape the large piece on top. The above right photo is what the switch looks like from the side once it is all together.
Step 3: Connect the switch to your micro:bit
We want the switch to be activated when the two pieces of aluminum foil touch. In order to do this, we need to connect one of the sides to the power source (pin 3V on the micro:bit), and the other side to one of the input pins (pin 0 on the micro:bit). This way, when the two pieces of foil are not touching the value of the pin will be 0, and when the two pieces of foil are touching the value of the pin will be 1.
Step 4: Programming your micro:bit
If you are not familiar with programming or using the micro:bit, we recommend visiting the official Getting Started page.
Otherwise, let's start writing some code. This will be a simple program that will show the state of our switch on the LED screen. It will show us a 0 when the switch is not pushed down, and will show us a 1 when the switch is pushed down and activated.
Grab a forever block from the Basic category in the micro:bit programming editor and put a show number block inside of it. Click on the Advanced category dropdown and then click on the Pins category. Place the digital read pin P0 block inside of the show number block.
Download the code and load it onto the micro:bit.
Step 5: Test and play!
Once you have uploaded the code from Step 4 onto the micro:bit and completed the wiring in Step 3, you can now test to see if your pad works.
References:What are we doing?We're building a create-your-own wearable kit to bring machine learning and statistics concepts to students. We envision students asking questions around sports performance such as, "How can I improve my tennis serve?", "What percentage of my shots are accurate over time?" or "Why doesn't our basketball team ever win?". They would then use wearable sensors to collect data from the body, analyze it using provided tools, and try to draw some conclusion. The bulk of this work involves building an app that allows the user to customize data collection and analysis from on-body sensors, and designing curricula to support use in secondary math and gym classes. This post will focus on our work on the application. To build the app, we need to enable four main functionalities:
Demo: Capturing video and sensor dataOur first goal was to make the Micro:bit's accelerometer data available in the app. We connected to the Micro:bit using bluetooth, calculated the magnitude of acceleration at each reading, and graphed the results over time.
At this stage, the accelerometer output was not actually synced to the video. In order to address this, we only have the app start collecting data from the accelerometer when the user presses the video record button, and stop when the user stops the video recording. The graph presents this data continuously over the time interval of the recording. The graph also acts as a timeline. The user can tap on parts of the graph and the video will go to that particular timestamp in the video. We are also now graphing x, y, and z acceleration instead of magnitude because it will be easier for the user to interpret that data. Check out what you can do with our app now:
Next StepsAn app like this generates a lot of data. We currently capture 10 (x,y,z) coordinates per second- for a five-minute video, we’d capture 3,000 points. We’ll also need to store segmented gestures, their labels, and classifications. This could get out of hand pretty quickly, so it’s important for us to develop a data storage system for the application. We’ll be using Apple's CoreData storage framework for this project because we are mainly concerned with local data storage (CoreData makes this pretty easy). We’re also building out 2. Allow user to segment gestures, assign labels and classifications. Users will identify the beginning and end of gestures, and assign a label (i.e. “slapshot”, “pass”). They’ll also be able to classify each gesture as “good” or “bad,” although we’ll later extend this to include an option for multiple classifications. This is an important next step in creating a foundation for users to explore machine learning. Signing off,
Abigail Zimmermann-Niefield, Bridget Murphy and Varun Narayanswamy
Annie Kelly
This tutorial will show you how to build your own micro:bit powered automated pet feeder.
Step 1: Preparing your supplies
This tutorial will be using a tiny programmable computer called the micro:bit, a servo, and basic craft and electronics materials. A lot of the following materials can be substituted, and doing so may result in your needing more or less than the other materials. This list is mostly suggestions.
1. Computer (laptop or desktop)
You will need to use a computer with internet access and a USB port to program the micro:bit.
2. micro:bit and a microUSB cable
You will need a micro:bit (~$12) and USB cable to complete this tutorial. Many retailers sell starter kits such as this one.
3. Servo
The servo will be the part of the feeder that is responsible for releasing food. Basically, it will be the mechanism that we can rotate over the opening of the bottle. In this tutorial we are using the Tower Pro MicroServo SG90, but any small ditial servo should do just fine.
4. Wire cutters/strippers
These will come in handy when we need to connect the servo to the micro:bit. If you do not have access to these tools you can use a pair of scissors to cut the wires and to carefully strip the ends.
5. Either alligator clips or soldering materials
In this tutorial I simply use alligator clips to connect the servo to the micro:bit, but for a more finished project you may want to consider soldering the connections so that they are more secure.
6. Bottle
Depending on the pet food you are using, you may want a smaller or larger bottle. Feel free to experiment with different sizes and different types of spouts. You might even find that you want to add a small paper funnel into the opening of the bottle to get better control over how much food is dispensed at any given time. In this tutorial I am using a small plastic spray bottle.
7. Glue and tape
This will be important when attatching all the different components of your pet feeder. In this tutorial I use hot glue to attach the servo directly to the bottle, but you could use tape or other materials instead.
8. Cardboard and scissors
I've found that a small cardboard box is really useful for making the structure of your pet feeder. In addition, I also use cardboard in this tutorial as part of the mechanism that keeps and releases food in the bootle.
9. Pet food!
Either your pet's favorite dry food or some treats.
Step 2: Assembling your pet feeder stand
First you will want to decide how you want to hold up your pet feeder. Since we will be relying on gravity to release the food from the feeder, we want to construct a stand so that the feeder bottle can be placed vertically with the opening facing downward. In addition we will want there to be space between the opening of the bottle and the floor (or table, bowl, etc.) That's why building a stand is useful.
In this tutorial, my stand is simply a cardboard box turned on its side.
To keep the top lip of the box sturdy for when we attach the rest of the feeder, I put 2 long pieces of masking tape that wrap under the top lip and attach all the way to the back of the box. This helps keep it raised despite having weight placed on it.
If you don't have a cardboard box handy or would prefer to use something else, go for it! You may want to attach your feeder directly to a wall in which case you don't need a stand, or maybe you would prefer to use an old plastic box you have in your garage. Feel free to experiment with different things, as you might find that you need a different type of stand depending on where you want this to go and how much weight you want it to support.
Step 3: Attaching the bottle to the stand
Note: You may decide you want to test the bottle with the servo before doing this step, in which case you can save this until later.
In this step I used hot glue to attach the bottle to the top lip of my cardboard box stand. I held it in place for about 1 minute as the glue dried to ensure that it didn't slide off while it was still hot.
Step 4: Setting up your servo and connecting it to the micro:bit
If you are using the same servo as me you will notice that your servo came with a few accessories. These can be attached to the knob at the top of the servo. I attached the simple one-armed piece to the top of mine (it pops right on, no other assembly necessary).
You will notice that at the end of the wires there is a black plastic attachment. If you have male to male wires you can just stick one end in each of the 3 holes to get access to its connections, or you can snip off the plastic part with some wire cutters or scissors. In this tutorial I snipped off the black plastic piece, stripped off the ends of the wires, and attached alligator clips to each wire.
Below you can see I attempted to color coordinate my clips with the wires to avoid confusion. Each color-coded wire has a different purpose:
Brown (attached to the black alligator clip): Ground Red (attached to the red alligator clip): Power Orange (attached to the yellow alligator clip): Signal If you have trouble distinguishing the colors of the wires you can use order instead to tell which is which. The center wire (red) is power, and the darker one next to it (brown) is ground, and the remaining one (orange) is signal. Now that you have your alligator clips attached and know the role of each wire, you can connect them to the micro:bit. Connect ground (brown/black) to the GND pin Connect power (red/red) to the 3V pin Connect signal (orange/yellow) to the 0 pin (you could also use 1 or 2 if you'd like, but you'll want to make a note of this for when we start programming in the next step). See photos below for reference. Step 5: Programming and testing your servo
Go to https://makecode.microbit.org/ to get to the micro:bit programming editor. If this is your first time programming a micro:bit you might want to visit their Getting Started page. Otherwise, let's continue.
To easily test out and play with our servo, let's create a program where the servo returns to its starting position (o degrees) when we push button A on the board, and have the servo rotate 90 degrees when we push button B. The button blocks can be found in the Input category in the programming editor, and the servo blocks can be found in the Advanced --> Pins category. Change the pin number to whichever pin you attached the servo's signal wire to, in this tutorial we are using pin 0 (P0).
Below is what the block program looks like (try clicking the little A and B buttons in the simulation below to see what happens to the servo):
And here is the corresponding JavaScript code (this can be copy and pasted into the editor if you click on the "JavaScript" tab):
input.onButtonPressed(Button.A, () => {
pins.servoWritePin(AnalogPin.P0, 0) }) input.onButtonPressed(Button.B, () => { pins.servoWritePin(AnalogPin.P0, 90) })
Now, plug your micro:bit's USB cable into the computer so that we can put our new program onto it. In the programming editor browser click the big blue "Download" button. You will now have a file in your downloads folder with a name that looks like "microbit-Untitled.hex" (if you changed the name of the project it will look similar except "Untitled" will be replaced with whatever you named it). Now you should be able to drag and drop that file onto your micro:bit. Again, if you are having issues with this step I recommend visiting the Getting Started page.
Once the program is successfully uploaded to the micro:bit you should see the servo turn 90 degrees when you press Button B, and return back to its original position when you press Button A. Step 6: Putting it all together
In this step we are going to attach some kind of a flap to the top of the servo, and then attach the servo to our bottle.
For my flap I just cut a rectangular piece of cardboard and hot glued it so it is perpendicular to the white plastic piece of the servo when it is in its starting position (0 degrees). I did this so when I attach it to the side of the bottle 0 degrees will mean the bottle opening is closed, and when the servo is at 90 degrees the bottle opening will be open and food will be released. To ensure the servo is in its starting position just press Button A on the micro:bit so that it turns to 0 degrees (assuming you completed Step 5).
Once the glue dried I started to glue the servo itself onto the plastic bottle. As you can see, the servo is at 0 degrees and the cardboard flap is holding the food inside of the bottle.
Now what?
Well now you can work on creative ways to trigger the food dispenser. Right now we have it so its controlled by 2 buttons, but you might want to explore working with different sensors and triggers. Have fun!
|