Ambient Bird
This project was completed during the Advanced Physical Computing course. This course had three distinct aspects, combined to create an overall goal. First of all we were tasked to create our own embedded software, without using anything but micro controllers as our CPU, meaning no Arduino/Raspberry and the like. In our case we used an ATMega8. Secondly the product would have to be ambient, able to pass as an object in the background, while still managing to complete it’s task Thirdly it had to give value to peoples lives, e.g. saving the environment, bringing people closer together etc.
Out of these requirements came the Ambird, an attempt to create a different tool to communicate in long-distance relationships. Each Ambird is paired with exactly one other Ambird, which is then given to the partner. By hovering your hand over the bird, and moving up and down, you could scroll through up to 8 preprogrammed colors and by whistling send that color to your paired device. The partner’s Ambird would then light with that color until cleared by hovering your hand above the lamp.
The idea was for the couple to develop their own language of colors to use, to communicate their mood or thoughts to each other without having to put in in words.
Technologies
The microcontroller was programmed using Basic.
The rest of the project was mainly consisting of piecing together small electronics such as sensors, LEDs and making circuit boards. Lastly, much effort also went into researching and proving that our solution gave value.
Code example
Below here is the sourcecode the AmBird. Written in basic for a ATMega32.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
$baud = 9600
$crystal = 8000000
'Ports setting up ports
'Using ADC on PortC4 and PortC5
'Rest of PortC is set as output manually to avoid
'overwriting the ADC configuration
Config Portb = Output
Config Portd = Output
Config Adc = Single , Prescaler = Auto
Config Portc.0 = Output
Config Portc.1 = Output
'Setting up Timer for PWM usage
'This allows us to send an 8bit value as analog output
'This is used for controlling the strength of the Red and Blue
'LEDs within the RBG-LED
'Theres only 2 of those ports on the ATmega8, hence why the green is not
'controlled in this way
Config Timer1 = Pwm , Pwm = 8 , Compare_a_pwm = Clear_up , Compare_b_pwm = Clear_up , Prescale = 1
'Declaring subs:
'Sets the color of the LED to predefined color. Parameter corresponds to a color
Declare Sub Setcolor(byval Color As Byte)
'Shuts off the RGB LEDs
Declare Sub Resetcolor()
'Blinks the LEDs on their current color a few times to signal
'that the color has been sent
Declare Sub Colorblink()
'Subs to set colors, to make the code look cleaner
Declare Sub Setgreen(byval Value As Byte) '2bit (0-3)
Declare Sub Setred(byval Value As Byte) '8bit (0-255)
Declare Sub Setblue(byval Value As Byte) '8bit (0-255)
'Takes a distance from the IR-sensor, and translates it to a number
'that corresponds to a color in the subroutine 'setcolor'
Declare Function Irtocolortranslater(byval Distance As Byte) As Byte
'Takes a value from the IR-sensor and translates it into a cm-value
'Will return 255 as an error value for debouncing purposes.
Declare Function Getirvalue() As Byte
'Checks the current input from the microphone, if higher than a predefined value
'it will return 1, otherwise 0
'Somehow we could not get this function to work with "bit" as value_type
Declare Function Ismicinputhigh() As Byte
'This function takes an ascii-input from the bluetooth
'and with a primitive method translates it to a color-number
Declare Function Translateinput(byval Asciival As Byte) As Byte
'Variables
'Holds a value for the current color displayed
Dim Localcolor As Byte
'Hold a value for the color received from the paired device
Dim Receivedcolor As Byte
'Flags to ensure the Do-loop runs as it should:
'This flag allows you to turn off a received signal with the IR
'Instead of starting to set a new color
Dim Hasreceivedcolor As Bit
'This prevents the Do-loop to reset the color that has been received
Dim Issettingcolor As Bit
'Used for debouncing in GetIrValue
'The Value read from the IR has to be the same multiple times in a row
'to avoid random reads from the IR to be returned.
Dim Debouncer1 As Byte
Dim Debouncer2 As Byte
Dim Debouncer3 As Byte
'The current value from the IR in cm
Dim Irvalue As Byte
'Setting up default values
Debouncer1 = 0
Debouncer2 = 0
Debouncer3 = 0
'The main loop of the program
Do
Irvalue = Getirvalue()
'If the IR-value (in centimeters) enter loop
While Irvalue >= 5 And Irvalue <= 25
Issettingcolor = 1
'If the current color has been received, turn it off
If Hasreceivedcolor = 1 Then
Call Resetcolor()
Hasreceivedcolor = 0
Waitms 4000
'Otherwise it means that the user wants to specify a color for
'him/her to send
Else
Localcolor = Irtocolortranslater(irvalue)
Call Setcolor(localcolor)
'Checks if the color currently selected should be sent
If Ismicinputhigh() = 1 Then
'transmit which color was selected to paired AmBird
Print Localcolor
'Colorblink is a visual feedback that shows the color has been sent
Call Colorblink()
End If
End If
Waitms 15
'To avoid the whileloop to run forever, we need to check for new IrValues
Irvalue = Getirvalue()
Wend
'This flag allows you to turn off a received signal with the IR
'Instead of starting to set a new color
If Issettingcolor = 1 And Irvalue <> 255 Then
Call Resetcolor()
Issettingcolor = 0
End If
'Checks if theres an input from the bluetooth component
'and that an illegal value hasnt been read from the IR
While Ischarwaiting() = 1 And Irvalue <> 255
Receivedcolor = Waitkey()
'convert from Ascii
Receivedcolor = Translateinput(receivedcolor)
If Receivedcolor > 0 And Receivedcolor < 7 Then
'Sets a flag
Hasreceivedcolor = 1
Call Setcolor(receivedcolor)
End If
Wend
Waitms 25
Loop
'Converts an Ascii number to a decimal number, very primitively
Function Translateinput(asciival As Byte)
Local P As Byte
P = Asciival - 48
Translateinput = P
End Function
'Returns 0 or 1 depending on the MicInput
Function Ismicinputhigh()
Local P As Word
P = Getadc(5)
If P > 505 And P < 1000 Then
Ismicinputhigh = 1
Else
Ismicinputhigh = 0
End If
End Function
'Gets a value from the IR-sensor and converts it to CM
'Then it saves the values in the Debouncers.
'If all the debouncer variables are equal to P
' (note That Debouncer1 Will Always Be Equal To P)
'Then The Value In Cm Is Returned, Otherwise Its Deemed As A Random Value
Function Getirvalue()
Local P As Integer
P = Getadc(4)
P = P - 11
P = 2076 / P
If P > 0 And P < 30 Then
Debouncer3 = Debouncer2
Debouncer2 = Debouncer1
Debouncer1 = P
If Debouncer2 = P And Debouncer3 = P Then
Getirvalue = P
Else
Getirvalue = 255
End If
Else
Getirvalue = 0
End If
End Function
'Translates a distance in CM to a number representing a color
Function Irtocolortranslater(byval Distance As Byte)
Local P As Byte
P = Distance
P = P - 2
P = P / 3
Irtocolortranslater = P
End Function
'Sets the green LEDs value with an R/R2 ladder
'and a binary value from 0-15
Sub Setgreen(value As Byte)
If Value < 4 Then
Reset Portc.0
Reset Portc.1
If Value >= 2 Then
Set Portc.1
Value = Value - 2
End If
If Value = 1 Then
Set Portc.0
Value = Value - 1
End If
End If
End Sub
'Set red LED with PWM
Sub Setred(value As Byte)
Pwm1a = Value
End Sub
'Set red LED with PWM
Sub Setblue(value As Byte)
Pwm1b = Value
End Sub
'Simple sub that blinks the current color and the shuts off the LED
Sub Colorblink()
Local A As Byte
For A = 1 To 3 Step 1
Call Resetcolor()
Waitms 600
Call Setcolor(localcolor)
Waitms 400
Next
Call Resetcolor()
Waitms 2000
End Sub
'Turns off the entire RGB-LED
Sub Resetcolor()
Pwm1a = 0
Pwm1b = 0
Reset Portc.0
Reset Portc.1
End Sub
'Sets a color depending on the value (controls both red, blue and green)
Sub Setcolor(color As Byte)
If Color >= 1 And Color <= 6 Then
Call Resetcolor()
Select Case Color
Case 1 : Call Setred(255) 'Red
Case 2 : Call Setred(255) 'purple
Call Setblue(255)
Case 3 : Call Setred(150) 'yellow
Call Setgreen(3)
Case 4 : Call Setgreen(3) 'green
Case 5 : Call Setgreen(3) 'teal
Call Setblue(60)
Case 6 : Call Setblue(255) 'blue
End Select
End If
End Sub
End
|