├── 2016 └── airlock │ └── edison │ ├── README.md │ ├── runner.cmd │ ├── runner.sh │ ├── step1.go │ ├── step10.go │ ├── step2.go │ ├── step3.go │ ├── step4.go │ ├── step5.go │ ├── step6.go │ ├── step7.go │ ├── step8.go │ └── step9.go ├── LICENSE.md ├── README.md ├── airlock └── tinytile │ ├── README.md │ ├── step1.go │ ├── step2.go │ ├── step3.go │ ├── step4.go │ ├── step5.go │ ├── step6.go │ ├── step7.go │ ├── step8.go │ └── step9.go ├── bounties └── README.md ├── drone └── minidrone │ ├── 1-takeoff.go │ ├── 2-data.go │ ├── 3-move.go │ ├── 4-flips.go │ ├── 5-freeflight.go │ ├── README.md │ └── dualshock3.json ├── images ├── arduino │ ├── step0.jpg │ ├── step0.png │ ├── step1.jpg │ ├── step1.png │ ├── step2.jpg │ ├── step2.png │ ├── step3.jpg │ ├── step3.png │ ├── step5.jpg │ ├── step5.png │ ├── step6.jpg │ └── step6.png ├── edison │ ├── step1.jpg │ ├── step10.jpg │ ├── step2.jpg │ ├── step3.jpg │ ├── step5.jpg │ ├── step6.jpg │ ├── step7.jpg │ ├── step8.jpg │ └── step9.jpg ├── starterkit │ ├── active-buzzer.png │ ├── analog-digital-ir-emmission-sensor.png │ ├── analog-digital-magnetic-reed-sensor.png │ ├── analog-digital-sound-sensor.png │ ├── analog-digital-temperature-sensor.png │ ├── analog-digital-touch-sensor.png │ ├── analog-joystick.png │ ├── analog-temperature-sensor.png │ ├── anaolg-digital-magnetic-feild-sensor.png │ ├── button.png │ ├── digital-ir-motion-sensor.png │ ├── digital-ir-reciever-sensor.png │ ├── digital-knock-hit-sensor.png │ ├── digital-laser-red.png │ ├── digital-line-finding-sensor.png │ ├── digital-magic-cup-mercury-tilt-sensor.png │ ├── digital-magnetic-reed-sensor.png │ ├── digital-magnetic-sensor.png │ ├── digital-mercury-tilt-sensor-with-led.png │ ├── digital-optical-break-sensor.png │ ├── digital-relay-with-led.png │ ├── digital-temp-sensor.png │ ├── digital-tilt-sensor.png │ ├── digital-vibration-sensor.png │ ├── fingerprint-heartbeat-detector.png │ ├── humidity-temperature-sensor.png │ ├── led-no-resistor.png │ ├── photo-resistor-sensor.png │ ├── red-green-led.png │ ├── rgb-flat-led.png │ ├── rgb-led.png │ └── rotary-encoder.png └── tinytile │ ├── step0.jpg │ ├── step1.jpg │ ├── step2.jpg │ └── step3.jpg ├── rover └── sprkplus │ ├── 1-color.go │ ├── 2-roll.go │ ├── ID.md │ └── README.md └── starterkit ├── README.md └── examples ├── analog-sound-example.go ├── digital-laser.go └── joystick.go /2016/airlock/edison/README.md: -------------------------------------------------------------------------------- 1 | # Airlock - Edison 2 | 3 | ## Installation 4 | 5 | ``` 6 | go get -d -u gobot.io/x/gobot/... 7 | ``` 8 | 9 | ## Setting up your board 10 | Follow the directions at the Edison site: 11 | 12 | https://software.intel.com/en-us/node/628232 13 | 14 | or just download the setup and follow the setup prompts: 15 | 16 | https://software.intel.com/iot/hardware/edison/downloads 17 | 18 | ## Finding and connecting to the Edison - OSX 19 | - Connect both USB cables to power and establish a serial connection 20 | - Run 21 | ``` 22 | ls /dev/cu.usbserial-* 23 | ``` 24 | - Copy the cu.usbserial-XXXXXX that is returned 25 | - Run 26 | ``` 27 | screen /dev/xx.usbserial-XXXXXXXX 115200 –L 28 | ``` 29 | - Press enter twice to login 30 | - Run ifconfig command and look for wlan0 entry 31 | 32 | ## Running the code 33 | When you run any of these examples, you will compile the code on your computer, move the compiled code onto the Intel Edison, and then execute the code on the Intel Edison itself, not on your own computer. 34 | 35 | We have included a shell script to make this process easier. You can run it like this: 36 | 37 | ``` 38 | $ ./runner.sh step1 192.168.1.42 39 | ``` 40 | Note: You'll use the IP Address you get during the setup process 41 | 42 | The `runner.sh` script performs the following steps for you: 43 | 44 | To compile the code: 45 | 46 | ``` 47 | $ GOARCH=386 GOOS=linux go build step1.go 48 | ``` 49 | 50 | Then to move the code to the Intel Edison, it uses the `scp` command: 51 | 52 | ``` 53 | $ scp step1 root@:/home/root/step1 54 | ``` 55 | 56 | Lastly, to execute it on your Edison, it uses the `ssh` command: 57 | 58 | ``` 59 | $ ssh -t root@ ./step1 60 | ``` 61 | 62 | ## Code 63 | 64 | ### step1.go - Blue LED 65 | 66 | ![Gobot](../../images/edison/step1.jpg) 67 | 68 | Connect the blue LED to D3. 69 | 70 | Run the code. 71 | 72 | You should see the blue LED blink. 73 | 74 | ### step2.go - Blue LED, Button 75 | 76 | ![Gobot](../../images/edison/step2.jpg) 77 | 78 | Connect the button to D2. 79 | 80 | Run the code. 81 | 82 | When you press the button, the blue LED should turn on. 83 | 84 | ### step3.go - Blue LED, Button, Green LED 85 | 86 | ![Gobot](../../images/edison/step3.jpg) 87 | 88 | Connect the Green LED to D4. 89 | 90 | Run the code. 91 | 92 | The green LED should light up. When you press the button, the blue LED should turn on, and the green LED should turn off. 93 | 94 | ### step4.go - Blue LED, Button, Green LED, Gobot API 95 | 96 | This step has us playing with the Gobot API. No additional hardware needs to be connected. 97 | 98 | Run the code. 99 | 100 | You can now point your web browser to `http://:3000` and try out the [Robeaux](https://github.com/hybridgroup/robeaux) web interface. 101 | 102 | ### step5.go - Blue LED, Button, Green LED, Gobot API, Buzzer, Touch 103 | 104 | ![Gobot](../../images/edison/step5.jpg) 105 | 106 | Connect the buzzer to D6, and connect the touch sensor to D8. 107 | 108 | Run the code. 109 | 110 | When your finger touches the capacitive touch sensor, the buzzer should sound. 111 | 112 | ### step6.go - Blue LED, Button, Green LED, Gobot API, Buzzer, Touch, Dial 113 | 114 | ![Gobot](../../images/edison/step6.jpg) 115 | 116 | Connect the rotary dial to A0. 117 | 118 | Run the code. 119 | 120 | Turning the dial will display the current analog reading on your console. 121 | 122 | ### step7.go - Blue LED, Button, Green LED, Gobot API, Buzzer, Touch, Dial, Temperature, Red LED 123 | 124 | ![Gobot](../../images/edison/step7.jpg) 125 | 126 | Connect the temperature sensor to A1, and the red LED to D5 127 | 128 | Run the code. 129 | 130 | By default, if the temperature exceeds 15 degrees, then the red LED will light up. 131 | In case the room is warmer than 15 degrees, change the default temperature in step7.go. 132 | 133 | In order to increase the temperature of the sensor, hold it between your fingers and wait for the LED to light up. 134 | To turn the LED off, let go of the temperature sensor (note: the temperature will drop much slower than it increased). 135 | 136 | ### step8.go - Blue LED, Button, Green LED, Gobot API, Buzzer, Touch, Dial, Temperature, Red LED, Sound 137 | 138 | ![Gobot](../../images/edison/step8.jpg) 139 | 140 | Connect the sound sensor to A2. 141 | 142 | Run the code. 143 | 144 | When a sound is detected, the blue LED will light up, the sound sensor reading will be displayed on your computer's console. 145 | 146 | ### step9.go - Blue LED, Button, Green LED, Gobot API, Buzzer, Touch, Dial, Temperature, Red LED, Sound, Light 147 | 148 | ![Gobot](../../images/edison/step9.jpg) 149 | 150 | Connect the light sensor to A3. 151 | 152 | Run the code. 153 | 154 | When a light is detected, the blue LED will light up, and the light sensor reading will be displayed on your computer's console. 155 | 156 | ### step10.go - Blue LED, Button, Green LED, Gobot API, Buzzer, Touch, Dial, Temperature, Red LED, Sound, Light, LCD 157 | 158 | ![Gobot](../../images/edison/step10.jpg) 159 | 160 | Connect the LCD to any of the I2C ports on the Grove shield. 161 | 162 | Run the code. 163 | 164 | The LCD display will show informative messages, and also change the backlight color to match the color of whichever of the 3 LEDs is lit. 165 | 166 | ## License 167 | 168 | Copyright (c) 2015-2017 The Hybrid Group. Licensed under the MIT license. 169 | -------------------------------------------------------------------------------- /2016/airlock/edison/runner.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | if [%1] == [] goto usage 3 | if [%2] == [] goto usage 4 | 5 | rem If you're using putty, change these to pscp and plink 6 | set SCP=scp 7 | set SSH=ssh 8 | 9 | :good 10 | if [%3] == [runonly] goto run 11 | echo "Compiling..." 12 | set GOARCH=386 13 | set GOOS=linux 14 | go build %1.go 15 | if errorlevel 1 goto exit 16 | echo "Copying..." 17 | %SCP% %1 root@%2:/home/root/%1 18 | echo "Setting permissions..." 19 | %SSH% -t root@%2 chmod +x ./%1 20 | :run 21 | echo "Running..." 22 | %SSH% -t root@%2 ./%1 23 | goto exit 24 | 25 | :usage 26 | echo Usage %0 [go file] [target host] [runonly] 27 | echo Do not add the .go extension for [go file] 28 | echo target host may be a host name or an ip address 29 | echo Specify runonly to skip compilation and copying 30 | 31 | :exit -------------------------------------------------------------------------------- /2016/airlock/edison/runner.sh: -------------------------------------------------------------------------------- 1 | [ $# -eq 0 ] && { echo "Usage: $0 [step] [ipaddress]"; exit 1; } 2 | 3 | echo "Compiling..." 4 | GOARCH=386 GOOS=linux go build $1.go 5 | echo "Copying..." 6 | scp $1 root@$2:/home/root/$1 7 | echo "Running..." 8 | ssh -t root@$2 ./$1 9 | -------------------------------------------------------------------------------- /2016/airlock/edison/step1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | 6 | "gobot.io/x/gobot" 7 | "gobot.io/x/gobot/drivers/gpio" 8 | "gobot.io/x/gobot/platforms/intel-iot/edison" 9 | ) 10 | 11 | func main() { 12 | board := edison.NewAdaptor() 13 | blue := gpio.NewGroveLedDriver(board, "3") 14 | 15 | work := func() { 16 | gobot.Every(1*time.Second, func() { 17 | blue.Toggle() 18 | }) 19 | } 20 | 21 | robot := gobot.NewRobot("airlock", 22 | []gobot.Connection{board}, 23 | []gobot.Device{blue}, 24 | work, 25 | ) 26 | 27 | robot.Start() 28 | } 29 | -------------------------------------------------------------------------------- /2016/airlock/edison/step10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/api" 9 | "gobot.io/x/gobot/drivers/aio" 10 | "gobot.io/x/gobot/drivers/gpio" 11 | "gobot.io/x/gobot/drivers/i2c" 12 | "gobot.io/x/gobot/platforms/intel-iot/edison" 13 | ) 14 | 15 | var button *gpio.GroveButtonDriver 16 | var blue *gpio.GroveLedDriver 17 | var green *gpio.GroveLedDriver 18 | var red *gpio.GroveLedDriver 19 | var buzzer *gpio.GroveBuzzerDriver 20 | var touch *gpio.GroveTouchDriver 21 | var rotary *aio.GroveRotaryDriver 22 | var sensor *aio.GroveTemperatureSensorDriver 23 | var sound *aio.GroveSoundSensorDriver 24 | var light *aio.GroveLightSensorDriver 25 | var screen *i2c.GroveLcdDriver 26 | 27 | func DetectSound(level int) { 28 | if level >= 400 { 29 | Message("Sound detected") 30 | TurnOff() 31 | Blue() 32 | time.Sleep(1 * time.Second) 33 | Reset() 34 | } 35 | } 36 | 37 | func DetectLight(level int) { 38 | if level >= 700 { 39 | Message("Light detected") 40 | TurnOff() 41 | Blue() 42 | time.Sleep(1 * time.Second) 43 | Reset() 44 | } 45 | } 46 | 47 | func CheckFireAlarm() { 48 | temp := sensor.Temperature() 49 | msg := fmt.Sprintf("Temp: %v", temp) 50 | Message(msg) 51 | if temp >= 40 { 52 | TurnOff() 53 | Red() 54 | buzzer.Tone(gpio.F4, gpio.Half) 55 | } 56 | } 57 | 58 | func Doorbell() { 59 | TurnOff() 60 | Blue() 61 | buzzer.Tone(gpio.C4, gpio.Quarter) 62 | time.Sleep(1 * time.Second) 63 | Reset() 64 | } 65 | 66 | func TurnOff() { 67 | red.Off() 68 | blue.Off() 69 | green.Off() 70 | } 71 | 72 | func Reset() { 73 | TurnOff() 74 | Message("Airlock ready.") 75 | Green() 76 | } 77 | 78 | func Message(text string) { 79 | fmt.Println(text) 80 | screen.Clear() 81 | screen.Home() 82 | screen.Write(text) 83 | } 84 | 85 | func Blue() { 86 | blue.On() 87 | screen.SetRGB(0, 0, 255) // blue 88 | } 89 | 90 | func Red() { 91 | red.On() 92 | screen.SetRGB(255, 0, 0) // red 93 | } 94 | 95 | func Green() { 96 | green.On() 97 | screen.SetRGB(0, 255, 0) // green 98 | } 99 | 100 | func main() { 101 | master := gobot.NewMaster() 102 | 103 | a := api.NewAPI(master) 104 | a.Start() 105 | 106 | board := edison.NewAdaptor() 107 | 108 | // digital 109 | button = gpio.NewGroveButtonDriver(board, "2") 110 | blue = gpio.NewGroveLedDriver(board, "3") 111 | green = gpio.NewGroveLedDriver(board, "4") 112 | red = gpio.NewGroveLedDriver(board, "5") 113 | buzzer = gpio.NewGroveBuzzerDriver(board, "6") 114 | touch = gpio.NewGroveTouchDriver(board, "8") 115 | 116 | // analog 117 | rotary = aio.NewGroveRotaryDriver(board, "0") 118 | sensor = aio.NewGroveTemperatureSensorDriver(board, "1") 119 | sound = aio.NewGroveSoundSensorDriver(board, "2") 120 | light = aio.NewGroveLightSensorDriver(board, "3") 121 | 122 | // i2c 123 | screen = i2c.NewGroveLcdDriver(board) 124 | 125 | work := func() { 126 | Reset() 127 | 128 | button.On(gpio.ButtonPush, func(data interface{}) { 129 | TurnOff() 130 | Message("On!") 131 | Blue() 132 | }) 133 | 134 | button.On(gpio.ButtonRelease, func(data interface{}) { 135 | Reset() 136 | }) 137 | 138 | touch.On(gpio.ButtonPush, func(data interface{}) { 139 | Doorbell() 140 | }) 141 | 142 | rotary.On(aio.Data, func(data interface{}) { 143 | b := uint8( 144 | gobot.ToScale(gobot.FromScale(float64(data.(int)), 0, 4096), 0, 255), 145 | ) 146 | blue.Brightness(b) 147 | }) 148 | 149 | sound.On(aio.Data, func(data interface{}) { 150 | DetectSound(data.(int)) 151 | }) 152 | 153 | light.On(aio.Data, func(data interface{}) { 154 | DetectLight(data.(int)) 155 | }) 156 | 157 | gobot.Every(1*time.Second, func() { 158 | CheckFireAlarm() 159 | }) 160 | } 161 | 162 | robot := gobot.NewRobot("airlock", 163 | []gobot.Connection{board}, 164 | []gobot.Device{button, blue, green, red, buzzer, touch, rotary, sensor, sound, light, screen}, 165 | work, 166 | ) 167 | 168 | master.AddRobot(robot) 169 | 170 | master.Start() 171 | } 172 | -------------------------------------------------------------------------------- /2016/airlock/edison/step2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gobot.io/x/gobot" 7 | "gobot.io/x/gobot/drivers/gpio" 8 | "gobot.io/x/gobot/platforms/intel-iot/edison" 9 | ) 10 | 11 | func main() { 12 | board := edison.NewAdaptor() 13 | button := gpio.NewGroveButtonDriver(board, "2") 14 | blue := gpio.NewGroveLedDriver(board, "3") 15 | 16 | work := func() { 17 | button.On(gpio.ButtonPush, func(data interface{}) { 18 | fmt.Println("On!") 19 | blue.On() 20 | }) 21 | 22 | button.On(gpio.ButtonRelease, func(data interface{}) { 23 | fmt.Println("Off!") 24 | blue.Off() 25 | }) 26 | } 27 | 28 | robot := gobot.NewRobot("airlock", 29 | []gobot.Connection{board}, 30 | []gobot.Device{button, blue}, 31 | work, 32 | ) 33 | 34 | robot.Start() 35 | } 36 | -------------------------------------------------------------------------------- /2016/airlock/edison/step3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gobot.io/x/gobot" 7 | "gobot.io/x/gobot/drivers/gpio" 8 | "gobot.io/x/gobot/platforms/intel-iot/edison" 9 | ) 10 | 11 | var button *gpio.GroveButtonDriver 12 | var blue *gpio.GroveLedDriver 13 | var green *gpio.GroveLedDriver 14 | 15 | func TurnOff() { 16 | blue.Off() 17 | green.Off() 18 | } 19 | 20 | func Reset() { 21 | TurnOff() 22 | fmt.Println("Airlock ready.") 23 | green.On() 24 | } 25 | 26 | func main() { 27 | board := edison.NewAdaptor() 28 | button = gpio.NewGroveButtonDriver(board, "2") 29 | blue = gpio.NewGroveLedDriver(board, "3") 30 | green = gpio.NewGroveLedDriver(board, "4") 31 | 32 | work := func() { 33 | Reset() 34 | 35 | button.On(gpio.ButtonPush, func(data interface{}) { 36 | TurnOff() 37 | fmt.Println("On!") 38 | blue.On() 39 | }) 40 | 41 | button.On(gpio.ButtonRelease, func(data interface{}) { 42 | Reset() 43 | }) 44 | } 45 | 46 | robot := gobot.NewRobot("airlock", 47 | []gobot.Connection{board}, 48 | []gobot.Device{button, blue, green}, 49 | work, 50 | ) 51 | 52 | robot.Start() 53 | } 54 | -------------------------------------------------------------------------------- /2016/airlock/edison/step4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gobot.io/x/gobot" 7 | "gobot.io/x/gobot/api" 8 | "gobot.io/x/gobot/drivers/gpio" 9 | "gobot.io/x/gobot/platforms/intel-iot/edison" 10 | ) 11 | 12 | var button *gpio.GroveButtonDriver 13 | var blue *gpio.GroveLedDriver 14 | var green *gpio.GroveLedDriver 15 | 16 | func TurnOff() { 17 | blue.Off() 18 | green.Off() 19 | } 20 | 21 | func Reset() { 22 | TurnOff() 23 | fmt.Println("Airlock ready.") 24 | green.On() 25 | } 26 | 27 | func main() { 28 | master := gobot.NewMaster() 29 | 30 | a := api.NewAPI(master) 31 | a.Start() 32 | 33 | board := edison.NewAdaptor() 34 | button = gpio.NewGroveButtonDriver(board, "2") 35 | blue = gpio.NewGroveLedDriver(board, "3") 36 | green = gpio.NewGroveLedDriver(board, "4") 37 | 38 | work := func() { 39 | Reset() 40 | 41 | button.On(gpio.ButtonPush, func(data interface{}) { 42 | TurnOff() 43 | fmt.Println("On!") 44 | blue.On() 45 | }) 46 | 47 | button.On(gpio.ButtonRelease, func(data interface{}) { 48 | Reset() 49 | }) 50 | } 51 | 52 | robot := gobot.NewRobot("airlock", 53 | []gobot.Connection{board}, 54 | []gobot.Device{button, blue, green}, 55 | work, 56 | ) 57 | 58 | master.AddRobot(robot) 59 | 60 | master.Start() 61 | } 62 | -------------------------------------------------------------------------------- /2016/airlock/edison/step5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/api" 9 | "gobot.io/x/gobot/drivers/gpio" 10 | "gobot.io/x/gobot/platforms/intel-iot/edison" 11 | ) 12 | 13 | var button *gpio.GroveButtonDriver 14 | var blue *gpio.GroveLedDriver 15 | var green *gpio.GroveLedDriver 16 | var buzzer *gpio.GroveBuzzerDriver 17 | var touch *gpio.GroveTouchDriver 18 | 19 | func Doorbell() { 20 | TurnOff() 21 | blue.On() 22 | buzzer.Tone(gpio.C4, gpio.Half) 23 | time.Sleep(1 * time.Second) 24 | Reset() 25 | } 26 | 27 | func TurnOff() { 28 | blue.Off() 29 | green.Off() 30 | } 31 | 32 | func Reset() { 33 | TurnOff() 34 | fmt.Println("Airlock ready.") 35 | green.On() 36 | } 37 | 38 | func main() { 39 | master := gobot.NewMaster() 40 | 41 | a := api.NewAPI(master) 42 | a.Start() 43 | 44 | board := edison.NewAdaptor() 45 | button = gpio.NewGroveButtonDriver(board, "2") 46 | blue = gpio.NewGroveLedDriver(board, "3") 47 | green = gpio.NewGroveLedDriver(board, "4") 48 | buzzer = gpio.NewGroveBuzzerDriver(board, "6") 49 | touch = gpio.NewGroveTouchDriver(board, "8") 50 | 51 | work := func() { 52 | Reset() 53 | 54 | button.On(gpio.ButtonPush, func(data interface{}) { 55 | TurnOff() 56 | fmt.Println("On!") 57 | blue.On() 58 | }) 59 | 60 | button.On(gpio.ButtonRelease, func(data interface{}) { 61 | Reset() 62 | }) 63 | 64 | touch.On(gpio.ButtonPush, func(data interface{}) { 65 | Doorbell() 66 | }) 67 | } 68 | 69 | robot := gobot.NewRobot("airlock", 70 | []gobot.Connection{board}, 71 | []gobot.Device{button, blue, green, buzzer, touch}, 72 | work, 73 | ) 74 | 75 | master.AddRobot(robot) 76 | 77 | master.Start() 78 | } 79 | -------------------------------------------------------------------------------- /2016/airlock/edison/step6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/api" 9 | "gobot.io/x/gobot/drivers/aio" 10 | "gobot.io/x/gobot/drivers/gpio" 11 | "gobot.io/x/gobot/platforms/intel-iot/edison" 12 | ) 13 | 14 | var button *gpio.GroveButtonDriver 15 | var blue *gpio.GroveLedDriver 16 | var green *gpio.GroveLedDriver 17 | var red *gpio.GroveLedDriver 18 | var buzzer *gpio.GroveBuzzerDriver 19 | var touch *gpio.GroveTouchDriver 20 | var rotary *aio.GroveRotaryDriver 21 | 22 | func Doorbell() { 23 | TurnOff() 24 | blue.On() 25 | buzzer.Tone(gpio.C4, gpio.Quarter) 26 | time.Sleep(1 * time.Second) 27 | Reset() 28 | } 29 | 30 | func TurnOff() { 31 | blue.Off() 32 | green.Off() 33 | } 34 | 35 | func Reset() { 36 | TurnOff() 37 | fmt.Println("Airlock ready.") 38 | green.On() 39 | } 40 | 41 | func main() { 42 | master := gobot.NewMaster() 43 | 44 | a := api.NewAPI(master) 45 | a.Start() 46 | 47 | // digital 48 | board := edison.NewAdaptor() 49 | button = gpio.NewGroveButtonDriver(board, "2") 50 | blue = gpio.NewGroveLedDriver(board, "3") 51 | green = gpio.NewGroveLedDriver(board, "4") 52 | red = gpio.NewGroveLedDriver(board, "5") 53 | buzzer = gpio.NewGroveBuzzerDriver(board, "6") 54 | touch = gpio.NewGroveTouchDriver(board, "8") 55 | 56 | // analog 57 | rotary = aio.NewGroveRotaryDriver(board, "0") 58 | 59 | work := func() { 60 | Reset() 61 | 62 | button.On(gpio.ButtonPush, func(data interface{}) { 63 | TurnOff() 64 | fmt.Println("On!") 65 | blue.On() 66 | }) 67 | 68 | button.On(gpio.ButtonRelease, func(data interface{}) { 69 | Reset() 70 | }) 71 | 72 | touch.On(gpio.ButtonPush, func(data interface{}) { 73 | Doorbell() 74 | }) 75 | 76 | rotary.On(aio.Data, func(data interface{}) { 77 | b := uint8( 78 | gobot.ToScale(gobot.FromScale(float64(data.(int)), 0, 4096), 0, 255), 79 | ) 80 | blue.Brightness(b) 81 | }) 82 | } 83 | 84 | robot := gobot.NewRobot("airlock", 85 | []gobot.Connection{board}, 86 | []gobot.Device{button, blue, green, buzzer, touch, rotary}, 87 | work, 88 | ) 89 | 90 | master.AddRobot(robot) 91 | 92 | master.Start() 93 | } 94 | -------------------------------------------------------------------------------- /2016/airlock/edison/step7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/api" 9 | "gobot.io/x/gobot/drivers/aio" 10 | "gobot.io/x/gobot/drivers/gpio" 11 | "gobot.io/x/gobot/platforms/intel-iot/edison" 12 | ) 13 | 14 | var button *gpio.GroveButtonDriver 15 | var blue *gpio.GroveLedDriver 16 | var green *gpio.GroveLedDriver 17 | var red *gpio.GroveLedDriver 18 | var buzzer *gpio.GroveBuzzerDriver 19 | var touch *gpio.GroveTouchDriver 20 | var rotary *aio.GroveRotaryDriver 21 | var sensor *aio.GroveTemperatureSensorDriver 22 | 23 | func CheckFireAlarm() { 24 | temp := sensor.Temperature() 25 | fmt.Println("Current temperature:", temp) 26 | if temp >= 15 { 27 | TurnOff() 28 | red.On() 29 | buzzer.Tone(gpio.F4, gpio.Half) 30 | } 31 | } 32 | 33 | func Doorbell() { 34 | TurnOff() 35 | blue.On() 36 | buzzer.Tone(gpio.C4, gpio.Quarter) 37 | time.Sleep(1 * time.Second) 38 | Reset() 39 | } 40 | 41 | func TurnOff() { 42 | blue.Off() 43 | green.Off() 44 | } 45 | 46 | func Reset() { 47 | TurnOff() 48 | fmt.Println("Airlock ready.") 49 | green.On() 50 | } 51 | 52 | func main() { 53 | master := gobot.NewMaster() 54 | 55 | a := api.NewAPI(master) 56 | a.Start() 57 | 58 | board := edison.NewAdaptor() 59 | 60 | // digital 61 | button = gpio.NewGroveButtonDriver(board, "2") 62 | blue = gpio.NewGroveLedDriver(board, "3") 63 | green = gpio.NewGroveLedDriver(board, "4") 64 | red = gpio.NewGroveLedDriver(board, "5") 65 | buzzer = gpio.NewGroveBuzzerDriver(board, "6") 66 | touch = gpio.NewGroveTouchDriver(board, "8") 67 | 68 | // analog 69 | rotary = aio.NewGroveRotaryDriver(board, "0") 70 | sensor = aio.NewGroveTemperatureSensorDriver(board, "1") 71 | 72 | work := func() { 73 | Reset() 74 | 75 | button.On(gpio.ButtonPush, func(data interface{}) { 76 | TurnOff() 77 | fmt.Println("On!") 78 | blue.On() 79 | }) 80 | 81 | button.On(gpio.ButtonRelease, func(data interface{}) { 82 | Reset() 83 | }) 84 | 85 | touch.On(gpio.ButtonPush, func(data interface{}) { 86 | Doorbell() 87 | }) 88 | 89 | gobot.Every(1*time.Second, func() { 90 | CheckFireAlarm() 91 | }) 92 | } 93 | 94 | robot := gobot.NewRobot("airlock", 95 | []gobot.Connection{board}, 96 | []gobot.Device{button, blue, green, red, buzzer, touch, rotary, sensor}, 97 | work, 98 | ) 99 | 100 | master.AddRobot(robot) 101 | 102 | master.Start() 103 | } 104 | -------------------------------------------------------------------------------- /2016/airlock/edison/step8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/api" 9 | "gobot.io/x/gobot/drivers/aio" 10 | "gobot.io/x/gobot/drivers/gpio" 11 | "gobot.io/x/gobot/platforms/intel-iot/edison" 12 | ) 13 | 14 | var button *gpio.GroveButtonDriver 15 | var blue *gpio.GroveLedDriver 16 | var green *gpio.GroveLedDriver 17 | var red *gpio.GroveLedDriver 18 | var buzzer *gpio.GroveBuzzerDriver 19 | var touch *gpio.GroveTouchDriver 20 | var rotary *aio.GroveRotaryDriver 21 | var sensor *aio.GroveTemperatureSensorDriver 22 | var sound *aio.GroveSoundSensorDriver 23 | 24 | func DetectSound(level int) { 25 | if level >= 400 { 26 | fmt.Println("Sound detected") 27 | TurnOff() 28 | blue.On() 29 | time.Sleep(1 * time.Second) 30 | Reset() 31 | } 32 | } 33 | 34 | func CheckFireAlarm() { 35 | temp := sensor.Temperature() 36 | fmt.Println("Current temperature:", temp) 37 | if temp >= 40 { 38 | TurnOff() 39 | red.On() 40 | buzzer.Tone(gpio.F4, gpio.Half) 41 | } 42 | } 43 | 44 | func Doorbell() { 45 | TurnOff() 46 | blue.On() 47 | buzzer.Tone(gpio.C4, gpio.Quarter) 48 | time.Sleep(1 * time.Second) 49 | Reset() 50 | } 51 | 52 | func TurnOff() { 53 | blue.Off() 54 | green.Off() 55 | } 56 | 57 | func Reset() { 58 | TurnOff() 59 | fmt.Println("Airlock ready.") 60 | green.On() 61 | } 62 | 63 | func main() { 64 | master := gobot.NewMaster() 65 | 66 | a := api.NewAPI(master) 67 | a.Start() 68 | 69 | board := edison.NewAdaptor() 70 | 71 | // digital 72 | button = gpio.NewGroveButtonDriver(board, "2") 73 | blue = gpio.NewGroveLedDriver(board, "3") 74 | green = gpio.NewGroveLedDriver(board, "4") 75 | red = gpio.NewGroveLedDriver(board, "5") 76 | buzzer = gpio.NewGroveBuzzerDriver(board, "6") 77 | touch = gpio.NewGroveTouchDriver(board, "8") 78 | 79 | // analog 80 | rotary = aio.NewGroveRotaryDriver(board, "0") 81 | sensor = aio.NewGroveTemperatureSensorDriver(board, "1") 82 | sound = aio.NewGroveSoundSensorDriver(board, "2") 83 | 84 | work := func() { 85 | Reset() 86 | 87 | button.On(gpio.ButtonPush, func(data interface{}) { 88 | TurnOff() 89 | fmt.Println("On!") 90 | blue.On() 91 | }) 92 | 93 | button.On(gpio.ButtonRelease, func(data interface{}) { 94 | Reset() 95 | }) 96 | 97 | button.On(gpio.ButtonPush, func(data interface{}) { 98 | Doorbell() 99 | }) 100 | 101 | rotary.On(aio.Data, func(data interface{}) { 102 | b := uint8( 103 | gobot.ToScale(gobot.FromScale(float64(data.(int)), 0, 4096), 0, 255), 104 | ) 105 | blue.Brightness(b) 106 | }) 107 | 108 | sound.On(aio.Data, func(data interface{}) { 109 | DetectSound(data.(int)) 110 | }) 111 | 112 | gobot.Every(1*time.Second, func() { 113 | CheckFireAlarm() 114 | }) 115 | } 116 | 117 | robot := gobot.NewRobot("airlock", 118 | []gobot.Connection{board}, 119 | []gobot.Device{button, blue, green, red, buzzer, touch, rotary, sensor, sound}, 120 | work, 121 | ) 122 | 123 | master.AddRobot(robot) 124 | 125 | master.Start() 126 | } 127 | -------------------------------------------------------------------------------- /2016/airlock/edison/step9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/api" 9 | "gobot.io/x/gobot/drivers/aio" 10 | "gobot.io/x/gobot/drivers/gpio" 11 | "gobot.io/x/gobot/platforms/intel-iot/edison" 12 | ) 13 | 14 | var button *gpio.GroveButtonDriver 15 | var blue *gpio.GroveLedDriver 16 | var green *gpio.GroveLedDriver 17 | var red *gpio.GroveLedDriver 18 | var buzzer *gpio.GroveBuzzerDriver 19 | var touch *gpio.GroveTouchDriver 20 | var rotary *aio.GroveRotaryDriver 21 | var sensor *aio.GroveTemperatureSensorDriver 22 | var sound *aio.GroveSoundSensorDriver 23 | var light *aio.GroveLightSensorDriver 24 | 25 | func DetectSound(level int) { 26 | if level >= 400 { 27 | fmt.Println("Sound detected") 28 | TurnOff() 29 | blue.On() 30 | time.Sleep(1 * time.Second) 31 | Reset() 32 | } 33 | } 34 | 35 | func DetectLight(level int) { 36 | if level >= 400 { 37 | fmt.Println("Light detected") 38 | TurnOff() 39 | blue.On() 40 | time.Sleep(1 * time.Second) 41 | Reset() 42 | } 43 | } 44 | 45 | func CheckFireAlarm() { 46 | temp := sensor.Temperature() 47 | fmt.Println("Current temperature:", temp) 48 | if temp >= 40 { 49 | TurnOff() 50 | red.On() 51 | buzzer.Tone(gpio.F4, gpio.Half) 52 | } 53 | } 54 | 55 | func Doorbell() { 56 | TurnOff() 57 | blue.On() 58 | buzzer.Tone(gpio.C4, gpio.Quarter) 59 | <-time.After(1 * time.Second) 60 | Reset() 61 | } 62 | 63 | func TurnOff() { 64 | blue.Off() 65 | green.Off() 66 | } 67 | 68 | func Reset() { 69 | TurnOff() 70 | fmt.Println("Airlock ready.") 71 | green.On() 72 | } 73 | 74 | func main() { 75 | master := gobot.NewMaster() 76 | 77 | a := api.NewAPI(master) 78 | a.Start() 79 | 80 | board := edison.NewAdaptor() 81 | 82 | // digital 83 | button = gpio.NewGroveButtonDriver(board, "2") 84 | blue = gpio.NewGroveLedDriver(board, "3") 85 | green = gpio.NewGroveLedDriver(board, "4") 86 | red = gpio.NewGroveLedDriver(board, "5") 87 | buzzer = gpio.NewGroveBuzzerDriver(board, "6") 88 | touch = gpio.NewGroveTouchDriver(board, "8") 89 | 90 | // analog 91 | rotary = aio.NewGroveRotaryDriver(board, "0") 92 | sensor = aio.NewGroveTemperatureSensorDriver(board, "1") 93 | sound = aio.NewGroveSoundSensorDriver(board, "2") 94 | light = aio.NewGroveLightSensorDriver(board, "3") 95 | 96 | work := func() { 97 | Reset() 98 | 99 | button.On(gpio.ButtonPush, func(data interface{}) { 100 | TurnOff() 101 | fmt.Println("On!") 102 | blue.On() 103 | }) 104 | 105 | button.On(gpio.ButtonRelease, func(data interface{}) { 106 | Reset() 107 | }) 108 | 109 | touch.On(gpio.ButtonPush, func(data interface{}) { 110 | Doorbell() 111 | }) 112 | 113 | rotary.On(aio.Data, func(data interface{}) { 114 | b := uint8( 115 | gobot.ToScale(gobot.FromScale(float64(data.(int)), 0, 4096), 0, 255), 116 | ) 117 | blue.Brightness(b) 118 | }) 119 | 120 | sound.On(aio.Data, func(data interface{}) { 121 | DetectSound(data.(int)) 122 | }) 123 | 124 | light.On(aio.Data, func(data interface{}) { 125 | DetectLight(data.(int)) 126 | }) 127 | 128 | gobot.Every(1*time.Second, func() { 129 | CheckFireAlarm() 130 | }) 131 | } 132 | 133 | robot := gobot.NewRobot("airlock", 134 | []gobot.Connection{board}, 135 | []gobot.Device{button, blue, green, red, buzzer, touch, rotary, sensor, sound, light}, 136 | work, 137 | ) 138 | 139 | master.AddRobot(robot) 140 | 141 | master.Start() 142 | } 143 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2015-2017 The Hybrid Group 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gobot Workshop 2017 2 | 3 | This is the information for the Gobot (https://gobot.io) community day for 2017. Read on, to discover all of the wonderful things we have in store. 4 | 5 | ## Gobot Starter Kit featuring the Intel TinyTILE - Giveaway Gear 6 | 7 | We have a lot of gear for you to use at today's hardware party. If you are one of the lucky 150 individuals who arrives early enough, you will receive a brand new Gobot Starter Kit featuring the Intel TinyTILE! 8 | 9 | For more info on the Gobot Starter Kit, check out: 10 | 11 | [./starterkit/README.md](./starterkit/README.md) 12 | 13 | PLEASE NOTE: If we run out of equipment, we ask that those who have received gear pair up with those who have not. Thank you! 14 | 15 | ## Lending Lab Gear 16 | 17 | We have also brought a bunch of other equipment for you to try out, and then return back to us when you are finished exploring it: 18 | 19 | - Sphero SPRK+ Robots 20 | - Parrot Minidrones 21 | - LIDAR laser range finders 22 | - Makey-Makeys 23 | - Leap Motion Gestural Controllers 24 | 25 | ## Bounties 26 | 27 | Like last year, we have some equipment "bounties". If you can contribute back to Gobot by adding software support for that platform, you could take home one of several awesome new devices, such as a GoPiGo3 Raspberry Pi powered Robot. For more info, go to: 28 | 29 | [./bounties/README.md](./bounties/README.md) 30 | 31 | ## Gophercon Gobot Challenges 32 | 33 | We have some self-directed "challenges" that you can follow along with using the Gobot Starter Kit, the Parrot Minidrone, and the Sphero SPRK+. 34 | 35 | ### Airlock 36 | 37 | Uses the Gobot Starter Kit to build a simulated airlock control system for our community base here on Planet Gophercon. 38 | 39 | [./airlock/tinytile/README.md](./airlock/tinytile/README.md) 40 | 41 | ### Drone 42 | 43 | Uses the Parrot Minidrone along with a PS3 controller to survey Planet Gophercon from above. 44 | 45 | [./drone/minidrone/README.md](./drone/minidrone/README.md) 46 | 47 | ### Rover 48 | 49 | Uses the Sphero SPRK+ to explore the surface of Planet Gophercon. 50 | 51 | [./rover/sprkplus/README.md](./rover/sprkplus/README.md) 52 | 53 | ## License 54 | 55 | Copyright (c) 2015-2017 The Hybrid Group. Licensed under the MIT license. 56 | -------------------------------------------------------------------------------- /airlock/tinytile/README.md: -------------------------------------------------------------------------------- 1 | # Airlock - TinyTILE 2 | 3 | ## Installation 4 | 5 | ``` 6 | go get -d -u gobot.io/x/gobot/... 7 | ``` 8 | 9 | ## Connecting the TinyTILE to your computer 10 | 11 | Plug the TinyTILE into your computer using the blue USB cable provided in your starter kit. The Firmata firmware that we use for controlling the TinyTILE from your computer has already been flashed onto the TinyTILE board. 12 | 13 | ## Running the code 14 | When you run any of these examples, you will compile and execute the code on your computer. 15 | 16 | To compile/run the code: 17 | 18 | ``` 19 | $ go run step1.go /dev/ttyACM0 20 | ``` 21 | 22 | If using Mac OS X then the TinyTILE will probably use a device name like `/dev/tty.usbmodem1421`. Perform a directory listing of `/dev/`; the TinyTILE is likely a device named using the pattern `/dev/tty.usbmodem`. 23 | 24 | Substitute the name of the program and the name of your serial port as needed. 25 | 26 | The Gobot program will use the serial interface to communicate with the connected TinyTILE that is running the Firmata firmware. Your TinyTILE already has Firmata installed for you. If you need to reload Firmata on your TinyTILE you can use Gort (http://gort.io) 27 | 28 | ## Code 29 | 30 | ![Gobot](../../images/tinytile/step0.jpg) 31 | 32 | First connect the power on the TinyTILE to the breadboard as follows: 33 | 34 | - Connect the GND pin on the TinyTILE to the breadboard's very bottom row using a black jumper cable. We will refer to this row of pins as the "GROUND RAIL". 35 | 36 | - Connect the 5V power pin on the TinyTILE to the breadboard's second row from the bottom using a red jumper cable. We will refer to this row of pins as the "POWER RAIL". 37 | 38 | On a breadboard, all of the pins in a horizontal row are connected to each other. So when we have a wire connected to one pin in that row, if we connect another in that same row, then both are connected to each other. 39 | 40 | ### step1.go - Blue LED 41 | 42 | ![Gobot](../../images/tinytile/step1.jpg) 43 | 44 | - Plug the RGB LED's blue pin "B" to the first row of pins on the breadboard on the right. Plug the RGB LED's ground pin "-" to the GROUND RAIL on the breadboard very bottom right. 45 | 46 | - Connect pin 3 on the TinyTILE to the same first row of pins on the breadboard next to the blue LED's pin. Choose any color of cable besides red or black. 47 | 48 | - Discover what tty is being used by your connection: `ls /dev/tty.*` 49 | 50 | Run the code. 51 | 52 | You should see the blue LED blink. 53 | 54 | ### step2.go - Blue LED, Button 55 | 56 | ![Gobot](../../images/tinytile/step2.jpg) 57 | 58 | - Connect pin 2 from the TinyTile to the signal pin (S) on the button. 59 | 60 | - Connect a red jumper cable from the power rail (+) on the breadboard to the middle pin on the button. 61 | 62 | - Connect a black jumper cable from the ground rail (-) on the breadboard to ground pin (2) on the button. 63 | 64 | Run the code. 65 | 66 | When you press the button, the blue LED should turn on. 67 | 68 | ### step3.go - Blue LED, Button, Green LED 69 | 70 | ![Gobot](../../images/tinytile/step3.jpg) 71 | 72 | - Plug a green jumper from pin 4 on the TinyTile to the middle pin on the Green LED. 73 | 74 | - Connect a jumper form the ground rail (-) on the breadboard to the blue LED's ground pin (-) using a black jumper cable. 75 | 76 | Run the code. 77 | 78 | The green LED should light up. When you press the button, the blue LED should turn on, and the green LED should turn off. 79 | 80 | ### step4.go - Blue LED, Button, Green LED, Gobot API 81 | 82 | This step has us playing with the Gobot API. No additional hardware needs to be connected. 83 | 84 | Run the code. 85 | 86 | You can now point your web browser to `http://localhost:3000` and try out the [Robeaux](https://github.com/hybridgroup/robeaux) web interface. 87 | 88 | ### step5.go - Blue LED, Button, Green LED, Gobot API, Buzzer, Additional Button 89 | 90 | ![Gobot](../../images/tinytile/step5.jpg) 91 | 92 | - Connect the buzzer to pin 16 on both sides of the breadboard. Make sure the plus (+) is on the left side. 93 | 94 | - Connect pin 16 on the right side of the breadboard to the ground rail (-) on the breadboard. 95 | 96 | - Connect pin 7 on the TinyTILE to pin 16 on the left side of the breadboard. 97 | 98 | - Connect the touch sensor to the breadboard so one side connects to pins 19 and 21 on one side of the gap, and connects to pins 19 and 21 on the other side of the gap. 99 | 100 | - Connect a red jumper cable from the power rail (+) on the breadboard to pin 19 on the breadboard. 101 | 102 | - Connect a 10K Ohm resistor from pin 21 on the breadboard to pin 23 on the breadboard. 103 | 104 | - Connect a black jumper cable from the ground rail (-) on the breadboard to pin 23 on the breadboard. 105 | 106 | - Connect pin 8 on the TinyTILE to pin 21 on the breadboard on the opposite side. Choose any color of cable besides red or black. 107 | 108 | Run the code. 109 | 110 | When you press the second button, the buzzer should sound. 111 | 112 | ### step6.go - Blue LED, Button, Green LED, Cylon.js API, Buzzer, Additional Button, Photoresistor 113 | 114 | ![Gobot](../../images/tinytile/step6.jpg) 115 | 116 | - Connect the Photoresistor to pin 26 on the breadboard and the power rail (+) on the breadboard. 117 | 118 | - Connect a 10K Ohm resistor from pin 26 on the breadboard to the ground rail (-) on the breadboard. 119 | 120 | - Connect pin A0 on the TinyTILE to pin 26 on the breadboard. Choose any color of cable besides red or black. 121 | 122 | Run the code. 123 | 124 | Changing the light level will display the current analog reading on your console. 125 | 126 | ## License 127 | 128 | Copyright (c) 2015-2017 The Hybrid Group. Licensed under the MIT license. 129 | -------------------------------------------------------------------------------- /airlock/tinytile/step1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "time" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/drivers/gpio" 9 | "gobot.io/x/gobot/platforms/firmata" 10 | ) 11 | 12 | func main() { 13 | board := firmata.NewAdaptor(os.Args[1]) 14 | blue := gpio.NewLedDriver(board, "3") 15 | 16 | work := func() { 17 | gobot.Every(1*time.Second, func() { 18 | blue.Toggle() 19 | }) 20 | } 21 | 22 | robot := gobot.NewRobot("airlock", 23 | []gobot.Connection{board}, 24 | []gobot.Device{blue}, 25 | work, 26 | ) 27 | 28 | robot.Start() 29 | } 30 | -------------------------------------------------------------------------------- /airlock/tinytile/step2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/drivers/gpio" 9 | "gobot.io/x/gobot/platforms/firmata" 10 | ) 11 | 12 | func main() { 13 | board := firmata.NewAdaptor(os.Args[1]) 14 | 15 | // digital devices 16 | button := gpio.NewButtonDriver(board, "2") 17 | blue := gpio.NewLedDriver(board, "3") 18 | 19 | work := func() { 20 | button.On(gpio.ButtonRelease, func(data interface{}) { 21 | fmt.Println("On!") 22 | blue.On() 23 | }) 24 | 25 | button.On(gpio.ButtonPush, func(data interface{}) { 26 | fmt.Println("Off!") 27 | blue.Off() 28 | }) 29 | } 30 | 31 | robot := gobot.NewRobot("airlock", 32 | []gobot.Connection{board}, 33 | []gobot.Device{button, blue}, 34 | work, 35 | ) 36 | 37 | robot.Start() 38 | } 39 | -------------------------------------------------------------------------------- /airlock/tinytile/step3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/drivers/gpio" 9 | "gobot.io/x/gobot/platforms/firmata" 10 | ) 11 | 12 | var button *gpio.ButtonDriver 13 | var blue *gpio.LedDriver 14 | var green *gpio.LedDriver 15 | 16 | func TurnOff() { 17 | blue.Off() 18 | green.Off() 19 | } 20 | 21 | func Reset() { 22 | TurnOff() 23 | fmt.Println("Airlock ready.") 24 | green.On() 25 | } 26 | 27 | func main() { 28 | board := firmata.NewAdaptor(os.Args[1]) 29 | 30 | // digital devices 31 | button = gpio.NewButtonDriver(board, "2") 32 | blue = gpio.NewLedDriver(board, "3") 33 | green = gpio.NewLedDriver(board, "4") 34 | 35 | work := func() { 36 | Reset() 37 | 38 | button.On(gpio.ButtonRelease, func(data interface{}) { 39 | TurnOff() 40 | fmt.Println("On!") 41 | blue.On() 42 | }) 43 | 44 | button.On(gpio.ButtonPush, func(data interface{}) { 45 | Reset() 46 | }) 47 | } 48 | 49 | robot := gobot.NewRobot("airlock", 50 | []gobot.Connection{board}, 51 | []gobot.Device{button, blue, green}, 52 | work, 53 | ) 54 | 55 | robot.Start() 56 | } 57 | -------------------------------------------------------------------------------- /airlock/tinytile/step4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/api" 9 | "gobot.io/x/gobot/drivers/gpio" 10 | "gobot.io/x/gobot/platforms/firmata" 11 | ) 12 | 13 | var button *gpio.ButtonDriver 14 | var blue *gpio.LedDriver 15 | var green *gpio.LedDriver 16 | 17 | func TurnOff() { 18 | blue.Off() 19 | green.Off() 20 | } 21 | 22 | func Reset() { 23 | TurnOff() 24 | fmt.Println("Airlock ready.") 25 | green.On() 26 | } 27 | 28 | func main() { 29 | master := gobot.NewMaster() 30 | 31 | a := api.NewAPI(master) 32 | a.Start() 33 | 34 | board := firmata.NewAdaptor(os.Args[1]) 35 | 36 | // digital devices 37 | button = gpio.NewButtonDriver(board, "2") 38 | blue = gpio.NewLedDriver(board, "3") 39 | green = gpio.NewLedDriver(board, "4") 40 | 41 | work := func() { 42 | Reset() 43 | 44 | button.On(gpio.ButtonRelease, func(data interface{}) { 45 | TurnOff() 46 | fmt.Println("On!") 47 | blue.On() 48 | }) 49 | 50 | button.On(gpio.ButtonPush, func(data interface{}) { 51 | Reset() 52 | }) 53 | } 54 | 55 | robot := gobot.NewRobot("airlock", 56 | []gobot.Connection{board}, 57 | []gobot.Device{button, blue, green}, 58 | work, 59 | ) 60 | 61 | master.AddRobot(robot) 62 | 63 | master.Start() 64 | } 65 | -------------------------------------------------------------------------------- /airlock/tinytile/step5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/api" 10 | "gobot.io/x/gobot/drivers/gpio" 11 | "gobot.io/x/gobot/platforms/firmata" 12 | ) 13 | 14 | var button *gpio.ButtonDriver 15 | var blue *gpio.LedDriver 16 | var green *gpio.LedDriver 17 | var buzzer *gpio.GroveBuzzerDriver 18 | var touch *gpio.ButtonDriver 19 | 20 | func Doorbell() { 21 | TurnOff() 22 | blue.On() 23 | buzzer.Tone(gpio.C4, gpio.Half) 24 | <-time.After(1 * time.Second) 25 | Reset() 26 | } 27 | 28 | func TurnOff() { 29 | blue.Off() 30 | green.Off() 31 | } 32 | 33 | func Reset() { 34 | TurnOff() 35 | fmt.Println("Airlock ready.") 36 | green.On() 37 | } 38 | 39 | func main() { 40 | master := gobot.NewMaster() 41 | 42 | a := api.NewAPI(master) 43 | a.Start() 44 | 45 | board := firmata.NewAdaptor(os.Args[1]) 46 | 47 | // digital devices 48 | button = gpio.NewButtonDriver(board, "2") 49 | blue = gpio.NewLedDriver(board, "3") 50 | green = gpio.NewLedDriver(board, "4") 51 | buzzer = gpio.NewGroveBuzzerDriver(board, "7") 52 | touch = gpio.NewButtonDriver(board, "8") 53 | 54 | work := func() { 55 | Reset() 56 | 57 | button.On(gpio.ButtonPush, func(data interface{}) { 58 | TurnOff() 59 | fmt.Println("On!") 60 | blue.On() 61 | }) 62 | 63 | button.On(gpio.ButtonRelease, func(data interface{}) { 64 | Reset() 65 | }) 66 | 67 | touch.On(gpio.ButtonPush, func(data interface{}) { 68 | Doorbell() 69 | }) 70 | } 71 | 72 | robot := gobot.NewRobot("airlock", 73 | []gobot.Connection{board}, 74 | []gobot.Device{button, blue, green, buzzer, touch}, 75 | work, 76 | ) 77 | 78 | master.AddRobot(robot) 79 | 80 | master.Start() 81 | } 82 | -------------------------------------------------------------------------------- /airlock/tinytile/step6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/api" 10 | "gobot.io/x/gobot/drivers/aio" 11 | "gobot.io/x/gobot/drivers/gpio" 12 | "gobot.io/x/gobot/platforms/firmata" 13 | ) 14 | 15 | var button *gpio.ButtonDriver 16 | var blue *gpio.LedDriver 17 | var green *gpio.LedDriver 18 | var buzzer *gpio.GroveBuzzerDriver 19 | var touch *gpio.ButtonDriver 20 | var light *aio.AnalogSensorDriver 21 | 22 | func Doorbell() { 23 | TurnOff() 24 | blue.On() 25 | buzzer.Tone(gpio.C4, gpio.Quarter) 26 | <-time.After(1 * time.Second) 27 | Reset() 28 | } 29 | 30 | func TurnOff() { 31 | blue.Off() 32 | green.Off() 33 | } 34 | 35 | func Reset() { 36 | TurnOff() 37 | fmt.Println("Airlock ready.") 38 | green.On() 39 | } 40 | 41 | func main() { 42 | master := gobot.NewMaster() 43 | 44 | a := api.NewAPI(master) 45 | a.Start() 46 | 47 | board := firmata.NewAdaptor(os.Args[1]) 48 | 49 | // digital devices 50 | button = gpio.NewButtonDriver(board, "2") 51 | blue = gpio.NewLedDriver(board, "3") 52 | green = gpio.NewLedDriver(board, "4") 53 | buzzer = gpio.NewGroveBuzzerDriver(board, "7") 54 | touch = gpio.NewButtonDriver(board, "8") 55 | 56 | // analog devices 57 | light = aio.NewAnalogSensorDriver(board, "0") 58 | 59 | work := func() { 60 | Reset() 61 | 62 | button.On(gpio.ButtonPush, func(data interface{}) { 63 | TurnOff() 64 | fmt.Println("On!") 65 | blue.On() 66 | }) 67 | 68 | button.On(gpio.ButtonRelease, func(data interface{}) { 69 | Reset() 70 | }) 71 | 72 | touch.On(gpio.ButtonPush, func(data interface{}) { 73 | Doorbell() 74 | }) 75 | 76 | light.On(aio.Data, func(data interface{}) { 77 | fmt.Println("light", data) 78 | }) 79 | } 80 | 81 | robot := gobot.NewRobot("airlock", 82 | []gobot.Connection{board}, 83 | []gobot.Device{button, blue, green, buzzer, touch, light}, 84 | work, 85 | ) 86 | 87 | master.AddRobot(robot) 88 | 89 | master.Start() 90 | } 91 | -------------------------------------------------------------------------------- /airlock/tinytile/step7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/api" 10 | "gobot.io/x/gobot/drivers/aio" 11 | "gobot.io/x/gobot/drivers/gpio" 12 | "gobot.io/x/gobot/platforms/firmata" 13 | ) 14 | 15 | var button *gpio.GroveButtonDriver 16 | var blue *gpio.GroveLedDriver 17 | var green *gpio.GroveLedDriver 18 | var red *gpio.GroveLedDriver 19 | var buzzer *gpio.GroveBuzzerDriver 20 | var touch *gpio.GroveTouchDriver 21 | var light *aio.AnalogSensorDriver 22 | var rotary *aio.GroveRotaryDriver 23 | var sensor *aio.GroveTemperatureSensorDriver 24 | 25 | func CheckFireAlarm() { 26 | temp := sensor.Temperature() 27 | fmt.Println("Current temperature:", temp) 28 | if temp >= 40 { 29 | TurnOff() 30 | red.On() 31 | buzzer.Tone(gpio.F4, gpio.Half) 32 | } 33 | } 34 | 35 | func Doorbell() { 36 | TurnOff() 37 | blue.On() 38 | buzzer.Tone(gpio.C4, gpio.Quarter) 39 | <-time.After(1 * time.Second) 40 | Reset() 41 | } 42 | 43 | func TurnOff() { 44 | blue.Off() 45 | green.Off() 46 | } 47 | 48 | func Reset() { 49 | TurnOff() 50 | fmt.Println("Airlock ready.") 51 | green.On() 52 | } 53 | 54 | func main() { 55 | master := gobot.NewMaster() 56 | 57 | a := api.NewAPI(master) 58 | a.Start() 59 | 60 | board := firmata.NewAdaptor(os.Args[1]) 61 | 62 | // digital devices 63 | button = gpio.NewGroveButtonDriver(board, "2") 64 | blue = gpio.NewGroveLedDriver(board, "3") 65 | green = gpio.NewGroveLedDriver(board, "4") 66 | red = gpio.NewGroveLedDriver(board, "5") 67 | buzzer = gpio.NewGroveBuzzerDriver(board, "7") 68 | touch = gpio.NewGroveTouchDriver(board, "8") 69 | 70 | // analog devices 71 | rotary = aio.NewGroveRotaryDriver(board, "0") 72 | sensor = aio.NewGroveTemperatureSensorDriver(board, "1") 73 | 74 | work := func() { 75 | Reset() 76 | 77 | button.On(gpio.ButtonPush, func(data interface{}) { 78 | TurnOff() 79 | fmt.Println("On!") 80 | blue.On() 81 | }) 82 | 83 | button.On(gpio.ButtonRelease, func(data interface{}) { 84 | Reset() 85 | }) 86 | 87 | button.On(gpio.ButtonPush, func(data interface{}) { 88 | Doorbell() 89 | }) 90 | 91 | rotary.On(aio.Data, func(data interface{}) { 92 | fmt.Println("rotary", data) 93 | }) 94 | 95 | gobot.Every(1*time.Second, func() { 96 | CheckFireAlarm() 97 | }) 98 | } 99 | 100 | robot := gobot.NewRobot("airlock", 101 | []gobot.Connection{board}, 102 | []gobot.Device{button, blue, green, red, buzzer, touch, rotary, sensor}, 103 | work, 104 | ) 105 | 106 | master.AddRobot(robot) 107 | 108 | master.Start() 109 | } 110 | -------------------------------------------------------------------------------- /airlock/tinytile/step8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/api" 10 | "gobot.io/x/gobot/drivers/aio" 11 | "gobot.io/x/gobot/drivers/gpio" 12 | "gobot.io/x/gobot/platforms/firmata" 13 | ) 14 | 15 | var button *gpio.GroveButtonDriver 16 | var blue *gpio.GroveLedDriver 17 | var green *gpio.GroveLedDriver 18 | var red *gpio.GroveLedDriver 19 | var buzzer *gpio.GroveBuzzerDriver 20 | var touch *gpio.GroveTouchDriver 21 | var light *aio.AnalogSensorDriver 22 | var rotary *aio.GroveRotaryDriver 23 | var sensor *aio.GroveTemperatureSensorDriver 24 | var sound *aio.GroveSoundSensorDriver 25 | 26 | func DetectSound(level int) { 27 | if level >= 400 { 28 | fmt.Println("Sound detected") 29 | TurnOff() 30 | blue.On() 31 | <-time.After(1 * time.Second) 32 | Reset() 33 | } 34 | } 35 | 36 | func CheckFireAlarm() { 37 | temp := sensor.Temperature() 38 | fmt.Println("Current temperature:", temp) 39 | if temp >= 40 { 40 | TurnOff() 41 | red.On() 42 | buzzer.Tone(gpio.F4, gpio.Half) 43 | } 44 | } 45 | 46 | func Doorbell() { 47 | TurnOff() 48 | blue.On() 49 | buzzer.Tone(gpio.C4, gpio.Quarter) 50 | <-time.After(1 * time.Second) 51 | Reset() 52 | } 53 | 54 | func TurnOff() { 55 | blue.Off() 56 | green.Off() 57 | } 58 | 59 | func Reset() { 60 | TurnOff() 61 | fmt.Println("Airlock ready.") 62 | green.On() 63 | } 64 | 65 | func main() { 66 | master := gobot.NewMaster() 67 | 68 | a := api.NewAPI(master) 69 | a.Start() 70 | 71 | board := firmata.NewAdaptor(os.Args[1]) 72 | 73 | // digital devices 74 | button = gpio.NewGroveButtonDriver(board, "2") 75 | blue = gpio.NewGroveLedDriver(board, "3") 76 | green = gpio.NewGroveLedDriver(board, "4") 77 | red = gpio.NewGroveLedDriver(board, "5") 78 | buzzer = gpio.NewGroveBuzzerDriver(board, "7") 79 | touch = gpio.NewGroveTouchDriver(board, "8") 80 | 81 | // analog devices 82 | rotary = aio.NewGroveRotaryDriver(board, "0") 83 | sensor = aio.NewGroveTemperatureSensorDriver(board, "1") 84 | sound = aio.NewGroveSoundSensorDriver(board, "2") 85 | 86 | work := func() { 87 | Reset() 88 | 89 | button.On(gpio.ButtonPush, func(data interface{}) { 90 | TurnOff() 91 | fmt.Println("On!") 92 | blue.On() 93 | }) 94 | 95 | button.On(gpio.ButtonRelease, func(data interface{}) { 96 | Reset() 97 | }) 98 | 99 | touch.On(gpio.ButtonPush, func(data interface{}) { 100 | Doorbell() 101 | }) 102 | 103 | rotary.On(aio.Data, func(data interface{}) { 104 | fmt.Println("rotary", data) 105 | }) 106 | 107 | sound.On(aio.Data, func(data interface{}) { 108 | DetectSound(data.(int)) 109 | }) 110 | 111 | gobot.Every(1*time.Second, func() { 112 | CheckFireAlarm() 113 | }) 114 | } 115 | 116 | robot := gobot.NewRobot("airlock", 117 | []gobot.Connection{board}, 118 | []gobot.Device{button, blue, green, red, buzzer, touch, rotary, sensor, sound}, 119 | work, 120 | ) 121 | 122 | master.AddRobot(robot) 123 | 124 | master.Start() 125 | } 126 | -------------------------------------------------------------------------------- /airlock/tinytile/step9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/api" 10 | "gobot.io/x/gobot/drivers/aio" 11 | "gobot.io/x/gobot/drivers/gpio" 12 | "gobot.io/x/gobot/platforms/firmata" 13 | ) 14 | 15 | var button *gpio.GroveButtonDriver 16 | var blue *gpio.GroveLedDriver 17 | var green *gpio.GroveLedDriver 18 | var red *gpio.GroveLedDriver 19 | var buzzer *gpio.GroveBuzzerDriver 20 | var touch *gpio.GroveTouchDriver 21 | var light *aio.GroveLightSensorDriver 22 | var rotary *aio.GroveRotaryDriver 23 | var sensor *aio.GroveTemperatureSensorDriver 24 | var sound *aio.GroveSoundSensorDriver 25 | 26 | func DetectSound(level int) { 27 | if level >= 400 { 28 | fmt.Println("Sound detected") 29 | TurnOff() 30 | blue.On() 31 | <-time.After(1 * time.Second) 32 | Reset() 33 | } 34 | } 35 | 36 | func DetectLight(level int) { 37 | if level >= 400 { 38 | fmt.Println("Light detected") 39 | TurnOff() 40 | blue.On() 41 | <-time.After(1 * time.Second) 42 | Reset() 43 | } 44 | } 45 | 46 | func CheckFireAlarm() { 47 | temp := sensor.Temperature() 48 | fmt.Println("Current temperature:", temp) 49 | if temp >= 40 { 50 | TurnOff() 51 | red.On() 52 | buzzer.Tone(gpio.F4, gpio.Half) 53 | } 54 | } 55 | 56 | func Doorbell() { 57 | TurnOff() 58 | blue.On() 59 | buzzer.Tone(gpio.C4, gpio.Quarter) 60 | <-time.After(1 * time.Second) 61 | Reset() 62 | } 63 | 64 | func TurnOff() { 65 | blue.Off() 66 | green.Off() 67 | } 68 | 69 | func Reset() { 70 | TurnOff() 71 | fmt.Println("Airlock ready.") 72 | green.On() 73 | } 74 | 75 | func main() { 76 | master := gobot.NewMaster() 77 | 78 | a := api.NewAPI(master) 79 | a.Start() 80 | 81 | board := firmata.NewAdaptor(os.Args[1]) 82 | 83 | // digital devices 84 | button = gpio.NewGroveButtonDriver(board, "2") 85 | blue = gpio.NewGroveLedDriver(board, "3") 86 | green = gpio.NewGroveLedDriver(board, "4") 87 | red = gpio.NewGroveLedDriver(board, "5") 88 | buzzer = gpio.NewGroveBuzzerDriver(board, "7") 89 | touch = gpio.NewGroveTouchDriver(board, "8") 90 | 91 | // analog devices 92 | rotary = aio.NewGroveRotaryDriver(board, "0") 93 | sensor = aio.NewGroveTemperatureSensorDriver(board, "1") 94 | sound = aio.NewGroveSoundSensorDriver(board, "2") 95 | light = aio.NewGroveLightSensorDriver(board, "3") 96 | 97 | work := func() { 98 | Reset() 99 | 100 | button.On(gpio.ButtonPush, func(data interface{}) { 101 | TurnOff() 102 | fmt.Println("On!") 103 | blue.On() 104 | }) 105 | 106 | button.On(gpio.ButtonRelease, func(data interface{}) { 107 | Reset() 108 | }) 109 | 110 | touch.On(gpio.ButtonPush, func(data interface{}) { 111 | Doorbell() 112 | }) 113 | 114 | rotary.On(aio.Data, func(data interface{}) { 115 | fmt.Println("rotary", data) 116 | }) 117 | 118 | sound.On(aio.Data, func(data interface{}) { 119 | DetectSound(data.(int)) 120 | }) 121 | 122 | light.On(aio.Data, func(data interface{}) { 123 | DetectLight(data.(int)) 124 | }) 125 | 126 | gobot.Every(1*time.Second, func() { 127 | CheckFireAlarm() 128 | }) 129 | } 130 | 131 | robot := gobot.NewRobot("airlock", 132 | []gobot.Connection{board}, 133 | []gobot.Device{button, blue, green, red, buzzer, touch, rotary, sensor, sound, light}, 134 | work, 135 | ) 136 | 137 | master.AddRobot(robot) 138 | 139 | master.Start() 140 | } 141 | -------------------------------------------------------------------------------- /bounties/README.md: -------------------------------------------------------------------------------- 1 | # Bounties 2017 2 | 3 | Like last year, we have some equipment "bounties". If you can contribute back to Gobot by adding software support you can take home one of the following awesome new devices: 4 | 5 | - GoPiGo3 Raspberry Pi powered Robot 6 | - Holy Stone HS220 Drone 7 | - Ultrasonic Rangefinder 8 | - Stepper Motor Controller 9 | 10 | ## GoPiGo3 11 | 12 | The GoPiGo3 is a Raspberry Pi powered robot kit. It uses a separate GoPiGo3 daughterboard to communicate between the Raspberry Pi and the various motors/sensors/etc. 13 | 14 | Some initial work on add the previous version of the GoPiGo was done in this PR, as a possible starting out point for this bounty: 15 | 16 | https://github.com/hybridgroup/gobot/pull/338 17 | 18 | Your mission is to add a Gobot adaptor/driver for the GoPiGo3 so we can run Gobot on the robot itself. 19 | 20 | ## Holy Stone HS220 Drone 21 | 22 | The Holy Stone HS110W/HS220 is a small battery operated quadcopter that has a connected "brain" and camera. The controller provides a WiFi access point and some kind of UDP based API. The API is not oficially documented, however information on one person's reverse engineering of its API using Node.js can be found here: 23 | 24 | https://github.com/lancecaraccioli/holystone-hs110w 25 | 26 | Your mission is to add a Gobot adaptor/driver for the HS110W/HS220 so we can run Gobot as a ground control station to control the drone. 27 | 28 | ## MCU Bounty 29 | 30 | Add anything else to Gobot, and we have an ESP8266 WiFi-connect microcontroller for you to take home and hack with. Yes! 31 | 32 | ## Ultrasonic Rangefinder 33 | 34 | ## Stepper Motor Controller 35 | -------------------------------------------------------------------------------- /drone/minidrone/1-takeoff.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/platforms/ble" 10 | "gobot.io/x/gobot/platforms/parrot/minidrone" 11 | ) 12 | 13 | func main() { 14 | bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 15 | drone := minidrone.NewDriver(bleAdaptor) 16 | 17 | work := func() { 18 | fmt.Println("takeoff...") 19 | drone.TakeOff() 20 | 21 | gobot.After(10*time.Second, func() { 22 | fmt.Println("landing...") 23 | drone.Land() 24 | }) 25 | } 26 | 27 | robot := gobot.NewRobot("minidrone", 28 | []gobot.Connection{bleAdaptor}, 29 | []gobot.Device{drone}, 30 | work, 31 | ) 32 | 33 | robot.Start() 34 | } 35 | -------------------------------------------------------------------------------- /drone/minidrone/2-data.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/platforms/ble" 10 | "gobot.io/x/gobot/platforms/parrot/minidrone" 11 | ) 12 | 13 | func main() { 14 | bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 15 | drone := minidrone.NewDriver(bleAdaptor) 16 | 17 | work := func() { 18 | drone.On(drone.Event("battery"), func(data interface{}) { 19 | fmt.Printf("battery: %d\n", data) 20 | }) 21 | 22 | drone.On(drone.Event("status"), func(data interface{}) { 23 | fmt.Printf("status: %d\n", data) 24 | }) 25 | 26 | drone.On(drone.Event("flying"), func(data interface{}) { 27 | fmt.Println("flying!") 28 | gobot.After(10*time.Second, func() { 29 | fmt.Println("landing...") 30 | drone.Land() 31 | }) 32 | }) 33 | 34 | drone.On(drone.Event("landed"), func(data interface{}) { 35 | fmt.Println("landed.") 36 | }) 37 | 38 | drone.TakeOff() 39 | } 40 | 41 | robot := gobot.NewRobot("minidrone", 42 | []gobot.Connection{bleAdaptor}, 43 | []gobot.Device{drone}, 44 | work, 45 | ) 46 | 47 | robot.Start() 48 | } 49 | -------------------------------------------------------------------------------- /drone/minidrone/3-move.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/platforms/ble" 10 | "gobot.io/x/gobot/platforms/parrot/minidrone" 11 | ) 12 | 13 | func main() { 14 | bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 15 | drone := minidrone.NewDriver(bleAdaptor) 16 | 17 | work := func() { 18 | drone.On(drone.Event("battery"), func(data interface{}) { 19 | fmt.Printf("battery: %d\n", data) 20 | }) 21 | 22 | drone.On(drone.Event("status"), func(data interface{}) { 23 | fmt.Printf("status: %d\n", data) 24 | }) 25 | 26 | drone.On(drone.Event("flying"), func(data interface{}) { 27 | fmt.Println("flying!") 28 | gobot.After(5*time.Second, func() { 29 | fmt.Println("forwards...") 30 | drone.Forward(10) 31 | }) 32 | gobot.After(10*time.Second, func() { 33 | fmt.Println("backwards...") 34 | drone.Backward(10) 35 | }) 36 | gobot.After(15*time.Second, func() { 37 | fmt.Println("right...") 38 | drone.Right(10) 39 | }) 40 | gobot.After(20*time.Second, func() { 41 | fmt.Println("left...") 42 | drone.Left(10) 43 | }) 44 | gobot.After(25*time.Second, func() { 45 | fmt.Println("landing...") 46 | drone.Land() 47 | }) 48 | }) 49 | 50 | drone.On(drone.Event("landed"), func(data interface{}) { 51 | fmt.Println("landed.") 52 | }) 53 | 54 | drone.TakeOff() 55 | } 56 | 57 | robot := gobot.NewRobot("minidrone", 58 | []gobot.Connection{bleAdaptor}, 59 | []gobot.Device{drone}, 60 | work, 61 | ) 62 | 63 | robot.Start() 64 | } 65 | -------------------------------------------------------------------------------- /drone/minidrone/4-flips.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/platforms/ble" 10 | "gobot.io/x/gobot/platforms/parrot/minidrone" 11 | ) 12 | 13 | func main() { 14 | bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 15 | drone := minidrone.NewDriver(bleAdaptor) 16 | 17 | work := func() { 18 | drone.On(drone.Event("battery"), func(data interface{}) { 19 | fmt.Printf("battery: %d\n", data) 20 | }) 21 | 22 | drone.On(drone.Event("status"), func(data interface{}) { 23 | fmt.Printf("status: %d\n", data) 24 | }) 25 | 26 | drone.On(drone.Event("flying"), func(data interface{}) { 27 | fmt.Println("flying!") 28 | gobot.After(10*time.Second, func() { 29 | fmt.Println("front flip!") 30 | drone.FrontFlip() 31 | }) 32 | gobot.After(20*time.Second, func() { 33 | fmt.Println("back flip!") 34 | drone.BackFlip() 35 | }) 36 | gobot.After(30*time.Second, func() { 37 | fmt.Println("landing...") 38 | drone.Land() 39 | }) 40 | }) 41 | 42 | drone.On(drone.Event("landed"), func(data interface{}) { 43 | fmt.Println("landed.") 44 | }) 45 | 46 | drone.TakeOff() 47 | } 48 | 49 | robot := gobot.NewRobot("minidrone", 50 | []gobot.Connection{bleAdaptor}, 51 | []gobot.Device{drone}, 52 | work, 53 | ) 54 | 55 | robot.Start() 56 | } 57 | -------------------------------------------------------------------------------- /drone/minidrone/5-freeflight.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "math" 5 | "os" 6 | "time" 7 | 8 | "gobot.io/x/gobot" 9 | "gobot.io/x/gobot/platforms/ble" 10 | "gobot.io/x/gobot/platforms/joystick" 11 | "gobot.io/x/gobot/platforms/parrot/minidrone" 12 | ) 13 | 14 | type pair struct { 15 | x float64 16 | y float64 17 | } 18 | 19 | func main() { 20 | pwd, _ := os.Getwd() 21 | joystickConfig := pwd + "/dualshock3.json" 22 | 23 | joystickAdaptor := joystick.NewAdaptor() 24 | joystick := joystick.NewDriver(joystickAdaptor, 25 | joystickConfig, 26 | ) 27 | 28 | droneAdaptor := ble.NewClientAdaptor(os.Args[1]) 29 | drone := minidrone.NewDriver(droneAdaptor) 30 | 31 | work := func() { 32 | offset := 32767.0 33 | rightStick := pair{x: 0, y: 0} 34 | leftStick := pair{x: 0, y: 0} 35 | 36 | joystick.On(joystick.Event("triangle_press"), func(data interface{}) { 37 | drone.TakeOff() 38 | }) 39 | joystick.On(joystick.Event("square_press"), func(data interface{}) { 40 | drone.Stop() 41 | }) 42 | joystick.On(joystick.Event("x_press"), func(data interface{}) { 43 | drone.Land() 44 | }) 45 | joystick.On(joystick.Event("left_x"), func(data interface{}) { 46 | val := float64(data.(int16)) 47 | if leftStick.x != val { 48 | leftStick.x = val 49 | } 50 | }) 51 | joystick.On(joystick.Event("left_y"), func(data interface{}) { 52 | val := float64(data.(int16)) 53 | if leftStick.y != val { 54 | leftStick.y = val 55 | } 56 | }) 57 | joystick.On(joystick.Event("right_x"), func(data interface{}) { 58 | val := float64(data.(int16)) 59 | if rightStick.x != val { 60 | rightStick.x = val 61 | } 62 | }) 63 | joystick.On(joystick.Event("right_y"), func(data interface{}) { 64 | val := float64(data.(int16)) 65 | if rightStick.y != val { 66 | rightStick.y = val 67 | } 68 | }) 69 | 70 | gobot.Every(10*time.Millisecond, func() { 71 | pair := rightStick 72 | if pair.y < -10 { 73 | drone.Forward(validatePitch(pair.y, offset)) 74 | } else if pair.y > 10 { 75 | drone.Backward(validatePitch(pair.y, offset)) 76 | } else { 77 | drone.Forward(0) 78 | } 79 | 80 | if pair.x > 10 { 81 | drone.Right(validatePitch(pair.x, offset)) 82 | } else if pair.x < -10 { 83 | drone.Left(validatePitch(pair.x, offset)) 84 | } else { 85 | drone.Right(0) 86 | } 87 | }) 88 | 89 | gobot.Every(10*time.Millisecond, func() { 90 | pair := leftStick 91 | if pair.y < -10 { 92 | drone.Up(validatePitch(pair.y, offset)) 93 | } else if pair.y > 10 { 94 | drone.Down(validatePitch(pair.y, offset)) 95 | } else { 96 | drone.Up(0) 97 | } 98 | 99 | if pair.x > 20 { 100 | drone.Clockwise(validatePitch(pair.x, offset)) 101 | } else if pair.x < -20 { 102 | drone.CounterClockwise(validatePitch(pair.x, offset)) 103 | } else { 104 | drone.Clockwise(0) 105 | } 106 | }) 107 | } 108 | 109 | robot := gobot.NewRobot("minidrone", 110 | []gobot.Connection{joystickAdaptor, droneAdaptor}, 111 | []gobot.Device{joystick, drone}, 112 | work, 113 | ) 114 | 115 | robot.Start() 116 | } 117 | 118 | func validatePitch(data float64, offset float64) int { 119 | value := math.Abs(data) / offset 120 | if value >= 0.1 { 121 | if value <= 1.0 { 122 | return int((float64(int(value*100)) / 100) * 100) 123 | } 124 | return 100 125 | } 126 | return 0 127 | } 128 | -------------------------------------------------------------------------------- /drone/minidrone/README.md: -------------------------------------------------------------------------------- 1 | # Drone - Parrot Minidrone 2 | 3 | ## Prereqs 4 | 5 | ### OS X 6 | 7 | ``` 8 | brew install pkg-config 9 | brew install sdl2 10 | ``` 11 | 12 | ### Linux 13 | 14 | Not yet... 15 | 16 | ## Installation 17 | 18 | ``` 19 | go get -d -u gobot.io/x/gobot/... 20 | ``` 21 | 22 | ## Running the code 23 | When you run any of these examples, you will compile and execute the code on your computer. When you are running the program, you will be communicating with the drone using the Bluetooth Low Energy (LE) interface. 24 | 25 | To compile/run the code, substitute the name of your drone as needed: 26 | 27 | ### OS X 28 | 29 | ``` 30 | $ GODEBUG=cgocheck=0 go run 5-freeflight.go RS_1234 31 | ``` 32 | 33 | ### Linux 34 | 35 | ``` 36 | go run 5-freeflight.go RS_1234 37 | ``` 38 | 39 | ## Code 40 | 41 | ### 1-takeoff.go 42 | 43 | ### 2-data.go 44 | 45 | ### 3-move.go 46 | 47 | ### 4-flips.go 48 | 49 | ### 5-flightcontrol.go 50 | 51 | ## License 52 | 53 | Copyright (c) 2015-2017 The Hybrid Group. Licensed under the MIT license. 54 | -------------------------------------------------------------------------------- /drone/minidrone/dualshock3.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Sony PLAYSTATION(R)3 Controller", 3 | "guid": "030000004c0500006802000011010000", 4 | "axis": [ 5 | { 6 | "name": "left_x", 7 | "id": 0 8 | }, 9 | { 10 | "name": "left_y", 11 | "id": 1 12 | }, 13 | { 14 | "name": "right_x", 15 | "id": 2 16 | }, 17 | { 18 | "name": "right_y", 19 | "id": 3 20 | } 21 | ], 22 | "buttons": [ 23 | { 24 | "name": "square", 25 | "id": 15 26 | }, 27 | { 28 | "name": "triangle", 29 | "id": 12 30 | }, 31 | { 32 | "name": "circle", 33 | "id": 13 34 | }, 35 | { 36 | "name": "x", 37 | "id": 14 38 | }, 39 | { 40 | "name": "up", 41 | "id": 4 42 | }, 43 | { 44 | "name": "down", 45 | "id": 6 46 | }, 47 | { 48 | "name": "left", 49 | "id": 7 50 | }, 51 | { 52 | "name": "right", 53 | "id": 5 54 | }, 55 | { 56 | "name": "left_stick", 57 | "id": 1 58 | }, 59 | { 60 | "name": "right_stick", 61 | "id": 2 62 | }, 63 | { 64 | "name": "l1", 65 | "id": 10 66 | }, 67 | { 68 | "name": "l2", 69 | "id": 8 70 | }, 71 | { 72 | "name": "r1", 73 | "id": 11 74 | }, 75 | { 76 | "name": "r2", 77 | "id": 9 78 | }, 79 | { 80 | "name": "start", 81 | "id": 3 82 | }, 83 | { 84 | "name": "select", 85 | "id": 0 86 | }, 87 | { 88 | "name": "home", 89 | "id": 16 90 | } 91 | ] 92 | } -------------------------------------------------------------------------------- /images/arduino/step0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step0.jpg -------------------------------------------------------------------------------- /images/arduino/step0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step0.png -------------------------------------------------------------------------------- /images/arduino/step1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step1.jpg -------------------------------------------------------------------------------- /images/arduino/step1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step1.png -------------------------------------------------------------------------------- /images/arduino/step2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step2.jpg -------------------------------------------------------------------------------- /images/arduino/step2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step2.png -------------------------------------------------------------------------------- /images/arduino/step3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step3.jpg -------------------------------------------------------------------------------- /images/arduino/step3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step3.png -------------------------------------------------------------------------------- /images/arduino/step5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step5.jpg -------------------------------------------------------------------------------- /images/arduino/step5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step5.png -------------------------------------------------------------------------------- /images/arduino/step6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step6.jpg -------------------------------------------------------------------------------- /images/arduino/step6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/arduino/step6.png -------------------------------------------------------------------------------- /images/edison/step1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/edison/step1.jpg -------------------------------------------------------------------------------- /images/edison/step10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/edison/step10.jpg -------------------------------------------------------------------------------- /images/edison/step2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/edison/step2.jpg -------------------------------------------------------------------------------- /images/edison/step3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/edison/step3.jpg -------------------------------------------------------------------------------- /images/edison/step5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/edison/step5.jpg -------------------------------------------------------------------------------- /images/edison/step6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/edison/step6.jpg -------------------------------------------------------------------------------- /images/edison/step7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/edison/step7.jpg -------------------------------------------------------------------------------- /images/edison/step8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/edison/step8.jpg -------------------------------------------------------------------------------- /images/edison/step9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/edison/step9.jpg -------------------------------------------------------------------------------- /images/starterkit/active-buzzer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/active-buzzer.png -------------------------------------------------------------------------------- /images/starterkit/analog-digital-ir-emmission-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/analog-digital-ir-emmission-sensor.png -------------------------------------------------------------------------------- /images/starterkit/analog-digital-magnetic-reed-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/analog-digital-magnetic-reed-sensor.png -------------------------------------------------------------------------------- /images/starterkit/analog-digital-sound-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/analog-digital-sound-sensor.png -------------------------------------------------------------------------------- /images/starterkit/analog-digital-temperature-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/analog-digital-temperature-sensor.png -------------------------------------------------------------------------------- /images/starterkit/analog-digital-touch-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/analog-digital-touch-sensor.png -------------------------------------------------------------------------------- /images/starterkit/analog-joystick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/analog-joystick.png -------------------------------------------------------------------------------- /images/starterkit/analog-temperature-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/analog-temperature-sensor.png -------------------------------------------------------------------------------- /images/starterkit/anaolg-digital-magnetic-feild-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/anaolg-digital-magnetic-feild-sensor.png -------------------------------------------------------------------------------- /images/starterkit/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/button.png -------------------------------------------------------------------------------- /images/starterkit/digital-ir-motion-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-ir-motion-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-ir-reciever-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-ir-reciever-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-knock-hit-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-knock-hit-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-laser-red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-laser-red.png -------------------------------------------------------------------------------- /images/starterkit/digital-line-finding-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-line-finding-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-magic-cup-mercury-tilt-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-magic-cup-mercury-tilt-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-magnetic-reed-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-magnetic-reed-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-magnetic-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-magnetic-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-mercury-tilt-sensor-with-led.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-mercury-tilt-sensor-with-led.png -------------------------------------------------------------------------------- /images/starterkit/digital-optical-break-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-optical-break-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-relay-with-led.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-relay-with-led.png -------------------------------------------------------------------------------- /images/starterkit/digital-temp-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-temp-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-tilt-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-tilt-sensor.png -------------------------------------------------------------------------------- /images/starterkit/digital-vibration-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/digital-vibration-sensor.png -------------------------------------------------------------------------------- /images/starterkit/fingerprint-heartbeat-detector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/fingerprint-heartbeat-detector.png -------------------------------------------------------------------------------- /images/starterkit/humidity-temperature-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/humidity-temperature-sensor.png -------------------------------------------------------------------------------- /images/starterkit/led-no-resistor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/led-no-resistor.png -------------------------------------------------------------------------------- /images/starterkit/photo-resistor-sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/photo-resistor-sensor.png -------------------------------------------------------------------------------- /images/starterkit/red-green-led.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/red-green-led.png -------------------------------------------------------------------------------- /images/starterkit/rgb-flat-led.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/rgb-flat-led.png -------------------------------------------------------------------------------- /images/starterkit/rgb-led.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/rgb-led.png -------------------------------------------------------------------------------- /images/starterkit/rotary-encoder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/starterkit/rotary-encoder.png -------------------------------------------------------------------------------- /images/tinytile/step0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/tinytile/step0.jpg -------------------------------------------------------------------------------- /images/tinytile/step1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/tinytile/step1.jpg -------------------------------------------------------------------------------- /images/tinytile/step2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/tinytile/step2.jpg -------------------------------------------------------------------------------- /images/tinytile/step3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hybridgroup/gophercon-2017/6e89c14f092e0f408554c4420bf8aa141d3e78ee/images/tinytile/step3.jpg -------------------------------------------------------------------------------- /rover/sprkplus/1-color.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "time" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/platforms/ble" 9 | "gobot.io/x/gobot/platforms/sphero/ollie" 10 | ) 11 | 12 | func main() { 13 | bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 14 | rover := ollie.NewDriver(bleAdaptor) 15 | 16 | work := func() { 17 | gobot.Every(1*time.Second, func() { 18 | r := uint8(gobot.Rand(255)) 19 | g := uint8(gobot.Rand(255)) 20 | b := uint8(gobot.Rand(255)) 21 | rover.SetRGB(r, g, b) 22 | }) 23 | } 24 | 25 | robot := gobot.NewRobot("ollieBot", 26 | []gobot.Connection{bleAdaptor}, 27 | []gobot.Device{rover}, 28 | work, 29 | ) 30 | 31 | robot.Start() 32 | } 33 | -------------------------------------------------------------------------------- /rover/sprkplus/2-roll.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "time" 6 | 7 | "gobot.io/x/gobot" 8 | "gobot.io/x/gobot/platforms/ble" 9 | "gobot.io/x/gobot/platforms/sphero/ollie" 10 | ) 11 | 12 | func main() { 13 | bleAdaptor := ble.NewClientAdaptor(os.Args[1]) 14 | rover := ollie.NewDriver(bleAdaptor) 15 | 16 | work := func() { 17 | gobot.Every(1*time.Second, func() { 18 | r := uint8(gobot.Rand(255)) 19 | g := uint8(gobot.Rand(255)) 20 | b := uint8(gobot.Rand(255)) 21 | rover.SetRGB(r, g, b) 22 | }) 23 | 24 | gobot.Every(3*time.Second, func() { 25 | rover.Roll(40, uint16(gobot.Rand(360))) 26 | }) 27 | } 28 | 29 | robot := gobot.NewRobot("ollieBot", 30 | []gobot.Connection{bleAdaptor}, 31 | []gobot.Device{rover}, 32 | work, 33 | ) 34 | 35 | robot.Start() 36 | } 37 | -------------------------------------------------------------------------------- /rover/sprkplus/ID.md: -------------------------------------------------------------------------------- 1 | "A" ) 2 | 3 | name: 2B-785E 4 | 5 | ID: cc360e85785e 6 | 7 | "B" ) 8 | 9 | name: 2B-BC7F 10 | 11 | ID: e5e9f094bc7f 12 | 13 | "C" ) 14 | 15 | name: 2B-48A8 16 | 17 | ID: f03e52ef48a8 18 | 19 | "D" ) 20 | 21 | name: 2B-9718 22 | 23 | ID: de4424879718 24 | 25 | "E" ) 26 | 27 | name: 2B-8A4F 28 | 29 | ID: d8aa6e238a4f 30 | 31 | "F" ) 32 | 33 | name: 2B-3965 34 | 35 | ID: f5e7a9973965 36 | 37 | "G" ) 38 | 39 | name: 2B-158C 40 | 41 | ID: eea31985158c 42 | 43 | "H" ) 44 | 45 | name: 2B-8189 46 | 47 | ID: c2595e6c8189 48 | 49 | "I" ) 50 | 51 | name: 2B-9AD3 52 | 53 | ID: d6456c0e9ad3 54 | 55 | "J" ) 56 | 57 | name: 2B-40C0 58 | 59 | ID: c5b946fd40c0 60 | 61 | "K" ) 62 | 63 | name: 2B-F57A 64 | 65 | ID: d5d2f41df57a 66 | 67 | "L" ) 68 | 69 | name: 2B-128E 70 | 71 | ID: c1cd28cf128e 72 | 73 | "M" ) 74 | 75 | name: 2B-4E9B 76 | 77 | ID: c80baa3d4e9b 78 | 79 | "N" ) 80 | 81 | name: 2B-1E17 82 | 83 | ID: d0472e631e17 84 | 85 | "O" ) 86 | 87 | name: 2B-3579 88 | 89 | ID: fdbb9f1e3579 90 | 91 | "P" ) 92 | 93 | name: 2B-F82F 94 | 95 | ID: f296b785f82f 96 | 97 | "Q" ) 98 | 99 | name: 2B-DCC6 100 | 101 | ID: daeba54fdcc6 102 | 103 | "R" ) 104 | 105 | name: 2B-6BDE 106 | 107 | ID: d068ab4f6bde 108 | 109 | "S" ) 110 | 111 | name: 2B-7C49 112 | 113 | ID: ee085cd87c49 114 | 115 | "T" ) 116 | 117 | name: 2B-588D 118 | 119 | ID: c9b76865588d 120 | -------------------------------------------------------------------------------- /rover/sprkplus/README.md: -------------------------------------------------------------------------------- 1 | # Rover - Sphero SPRK+ 2 | 3 | The Sphero SPRK+ uses the same BLE API at the Sphero BB-8 and Sphero Ollie. 4 | 5 | ## Installation 6 | 7 | ``` 8 | go get -d -u gobot.io/x/gobot/... 9 | ``` 10 | 11 | ## Running the code 12 | When you run any of these examples, you will compile and execute the code on your computer. When you are running the program, you will be communicating with the drone using the Bluetooth Low Energy (LE) interface. 13 | 14 | To compile/run the code, substitute the name of your Ollie or BB-8 as needed. 15 | 16 | ### OS X 17 | 18 | ``` 19 | $ go run 1-color.go BB-128E 20 | ``` 21 | 22 | ### Linux 23 | 24 | ``` 25 | $ go run 1-color.go BB-128E 26 | ``` 27 | 28 | ## Code 29 | 30 | ### 1-color.go 31 | 32 | ### 2-roll.go 33 | 34 | ## License 35 | 36 | Copyright (c) 2015-2017 The Hybrid Group. Licensed under the MIT license. 37 | -------------------------------------------------------------------------------- /starterkit/README.md: -------------------------------------------------------------------------------- 1 | # Gobot Starter Kit 2017 2 | 3 | The starter kit for the Gophercon 2017 Community Day! 4 | 5 | ## Intel TinyTILE 6 | 7 | The Intel TinyTILE is a small 3.3 volt microcontroller based on the Intel Curie System on Chip (SoC). It is Arduino-compatible, and also has a built-in 6-axis accelerometer, Bluetooth LE radio, and even a small neural net processor. 8 | 9 | For info on Gobot support for the Intel Curie based boards (TinyTILE and Arduino 101) go to: 10 | 11 | [https://gobot.io/documentation/platforms/curie/](https://gobot.io/documentation/platforms/curie/) 12 | 13 | ## Sensor Kit 14 | 15 | The Gobot Starter Kit includes 37 different small sensor or actuator boards. Some of them are variations of single sensor, but including some extra electronics for a specific use case, such as a digital threshold trigger. 16 | 17 | ### Sound Sensor 18 | 19 | ![](../images/starterkit/analog-digital-sound-sensor.png) 20 | 21 | This module can produce an analog signal to measure the sound threshold detected by the small microphone. This is not a good enough mic to actually record sound. 22 | 23 | In addition, the module sends a digital trigger, similar to how a button triggers when sound is detected. The threshold can be set using the small screw on the blue box. 24 | 25 | ### Light Sensor 26 | 27 | ![](../images/starterkit/photo-resistor-sensor.png) 28 | 29 | This module can produce an analog signal to measure the light level using a small photo luminescence resistor. 30 | 31 | ### Magnetic Sensor - Digital 32 | 33 | ![](../images/starterkit/digital-magnetic-sensor.png) 34 | 35 | This module can produce an digital signal to detect the presence of a very near magnetic field. 36 | 37 | ### Magnetic Sensor - Analog 38 | 39 | ![](../images/starterkit/digital-magnetic-sensor.png) 40 | 41 | This module can produce an analog signal to detect how near or far away is the presence of a very near magnetic field. 42 | 43 | ### Red/Green LED - Small 44 | 45 | ![](../images/starterkit/red-green-led.png) 46 | 47 | This module is a combination red and greed LED. 48 | 49 | "-" symbol is the ground pin, the middle pin is the positive for green and the end labeled "s" is the positive pin for red. 50 | 51 | ### Red/Green LED - Large 52 | 53 | ![](../images/starterkit/red-green-led.png) 54 | 55 | This module is another larger combination red and greed LED. 56 | 57 | "-" symbol is the ground pin, the middle pin is the positive for green and the end labeled "s" is the positive pin for red. 58 | 59 | ### Temperature Sensor 60 | 61 | ![](../images/starterkit/analog-temperature-sensor.png) 62 | 63 | This module can produce an analog signal to measure the ambient temperature. 64 | 65 | The ground pin is on the "-" symbol. The 5V is the center pin, and signal is an analog voltage on the "s" labeled pin. You will need to convert this voltage to determine the correct temperature from the voltage. 66 | 67 | ### Magnetic Sensor - Module 68 | 69 | ![](../images/starterkit/anaolg-digital-magnetic-feild-sensor.png) 70 | 71 | This module can produce an analog signal to detect how near or far away is the presence of a very near magnetic field. 72 | 73 | In addition, the module sends a digital trigger, similar to how a button triggers when a magnet is detected. The threshold can be set using the small screw on the blue box. 74 | 75 | There is a red led included on the board which turns on when magnet is detected. The "A0" is the analog signal pin, "G" is ground ", "+" is 5v positive, and "D0" digital trigger pin for this module. 76 | 77 | ### Temperature Sensor - Module 78 | 79 | ![](../images/starterkit/analog-digital-temperature-sensor.png) 80 | 81 | This module can produce an analog signal to measure the ambient temperature. You will need to convert the analog voltage to determine the correct temperature from the voltage. 82 | 83 | In addition, the module sends a digital trigger, similar to how a button triggers when a threshold of temperature is detected. The threshold can be set using the small screw on the blue box. 84 | 85 | The "A0" is analog pin, "G" is ground pin, "+" is 5v positive pin, "D0" pin is the digital trigger pin for this module. 86 | 87 | ### Touch Sensor - Module 88 | 89 | ![](../images/starterkit/analog-digital-touch-sensor.png) 90 | 91 | This module can produce an analog signal to measure when it is touched. 92 | 93 | In addition, the module sends a digital trigger, similar to how a button triggers when touch is detected. The threshold can be set using the small screw on the blue box. 94 | 95 | The "A0" pin is analog pin, "G" is ground pin, "+" is 5v positive pin, "D0" pin is the digital trigger pin. 96 | 97 | ### Magnetic Reed Module 98 | 99 | ![](../images/starterkit/analog-digital-magnetic-reed-sensor.png) 100 | 101 | This module can produce an analog signal to detect a magnet. It is known as a magnetic reed sensor. 102 | 103 | In addition, the module sends a digital trigger, similar to how a button triggers when magnetic field is detected. The threshold can be set using the small screw on the blue box. 104 | 105 | "A0" is analog signal pin, "G" is ground pin, "+" is 5v positive pin, "D0" pin is the digital trigger. There is also a built-in tiny red LED that signals when the magnet is near. 106 | 107 | ### RGB LED (flat) 108 | 109 | ![](../images/starterkit/rgb-flat-led.png) 110 | 111 | This module is a small flat RGB LED. Note that the pins on this board are mis-labeled. 112 | 113 | "-" symbol is ground pin, "R" symbol is GREEN positive pin, "G" symbol is RED positive pin, and "B" symbol is BLUE positive pin. 114 | 115 | ### Light Cup 116 | 117 | ![](../images/starterkit/digital-magic-cup-mercury-tilt-sensor.png) 118 | 119 | This module is a digital gravity powered mercury switch. Note that the LED on switch does not appear to work. 120 | 121 | "G" is ground pin, "+" is 5v positive pin, "S" is digital signal, "L" is 5v led which appears not to work. 122 | 123 | ### Infrared Emission Sensor 124 | 125 | ![](../images/starterkit/analog-digital-ir-emmission-sensor.png) 126 | 127 | This module is an analog/digital infrared sensor. 128 | 129 | In addition, the module sends a digital trigger, similar to how a button triggers when IR is detected. The threshold can be set using the small screw on the blue box. 130 | 131 | There is a small built-in 5v red signal LED included. 132 | 133 | "A0" is the analog pin, "G" is ground pin, "+" is 5v positive pin, "D0" pin is the digital pin for this module. 134 | 135 | ### RGB LED 136 | 137 | ![](../images/starterkit/rgb-led.png) 138 | 139 | This module is a small RGB LED. 140 | 141 | "-" symbol is ground pin, "G" symbol is GREEN positive pin, "R" symbol is red positive pin, and "B" symbol is blue positive pin. 142 | 143 | ### IR Sensor 144 | 145 | ![](../images/starterkit/digital-ir-reciever-sensor.png) 146 | 147 | This module is a IR light receiver such as that used by televisions. 148 | 149 | "-" is negative pin, "s" pin is the digital signal pin, and the middle pin is 5v positive. 150 | 151 | ### Magnetic Reed Switch 152 | 153 | ![](../images/starterkit/digital-magnetic-reed-sensor.png) 154 | 155 | digital magnetic reed switch "-" is negative, "s" pin is the digital signal pin and the middle pin is 5v positive 156 | 157 | ### Mercury Switch 158 | ![](../images/starterkit/digital-mercury-tilt-sensor-with-led.png) 159 | 160 | digital murcury switch with red LED, "-" is negative, "s" pin is the digital signal pin and the middle pin is 5v positive, tilt the switch to trigger the signal and the LED also turns on 161 | 162 | ### Hit Sensor - Module 163 | ![](../images/starterkit/digital-knock-hit-sensor.png) 164 | 165 | digital knock/hit sensor "-" is negative, "s" pin is the digital signal pin and the middle pin is 5v positive, the sensor is not sensitive must hit kinda hard to trigger 166 | 167 | ### Vibration Sensor 168 | ![](../images/starterkit/digital-vibration-sensor.png) 169 | 170 | Digital Vibration sensor "-" is negative, "s" pin is the digital signal pin and the middle pin is 5v positive 171 | 172 | ### Tilt Sensor 173 | ![](../images/starterkit/digital-tilt-sensor.png) 174 | 175 | digital tilt sensor "-" is negative, "s" pin is the digital signal pin and the middle pin is 5v positive 176 | 177 | ### Relay 178 | ![](../images/starterkit/digital-relay-with-led.png) 179 | 180 | digital relay with red led to signal open / close... I couln't get the output to light an led properly may need to test more "-" is negative, "s" pin is the digital signal pin and the middle pin is 5v positive 181 | 182 | ### Active Buzzer X2 183 | ![](../images/starterkit/active-buzzer.png) 184 | 185 | digital buzzer... one buzzer works correctly and the other buzzer "-" symbol == positive 186 | 187 | ### Push Button 188 | ![](../images/starterkit/button.png) 189 | 190 | simple push putton two modes either pushed or not pushed "-" is negative, "s" pin is the digital signal pin and the middle pin is 5v positive 191 | 192 | ### Joystick 193 | ![](../images/starterkit/analog-joystick.png) 194 | 195 | need to write a proper driver "gnd" is ground, "+5v" is 5v, "vrx" is x axis, "vry" is y axis, sw is presssing the button in 196 | 197 | ### Optical Break Sensor 198 | ![](../images/starterkit/digital-optical-break-sensor.png) 199 | 200 | not working atm with current tests 201 | 202 | ### Obstacle Avoidance Sensor 1 203 | ![](../images/starterkit/analog-digital-sound-sensor.png) 204 | 205 | digital ir motion sensor "gnd" is ground, "+" is 5v out is digital signal cable 206 | 207 | ### Line Finder 208 | ![](../images/starterkit/analog-digital-sound-sensor.png) 209 | 210 | digital line finder follows black line, need small flathead to adjust the sensativity, "g" is ground, "v+" is 5v positive, "s" is digital signal cable 211 | 212 | ### Fingerprint Heartbeat Detector 213 | 214 | ![](../images/starterkit/fingerprint-heartbeat-detector.png) 215 | 216 | needs math to work correctly 217 | this is what it looks like in arduino code 218 | 219 | ``` 220 | // Pulse Monitor Test Script 221 | 222 | int sensorPin = 0; 223 | double alpha = 0.75; 224 | int period = 100; 225 | double change = 0.0; 226 | double minval = 0.0; 227 | void setup () 228 | { 229 | Serial.begin (9600); 230 | } 231 | void loop () 232 | { 233 | static double oldValue = 0; 234 | static double oldChange = 0; 235 | 236 | int rawValue = analogRead (sensorPin); 237 | double value = alpha * oldValue + (1 - alpha) * rawValue; 238 | 239 | Serial.print (rawValue); 240 | Serial.print (","); 241 | Serial.println (value); 242 | oldValue = value; 243 | 244 | delay (period); 245 | } 246 | ``` 247 | 248 | ### Motion Sensor 249 | ![](../images/starterkit/digital-ir-motion-sensor.png) 250 | 251 | appears to be an ir motion detector 252 | 253 | ### LASER 254 | ![](../images/starterkit/digital-laser-red.png) 255 | 256 | digital red laser "-" is ground, middle wire is 5v positive, "s" is digital signal cable 257 | 258 | ### LED 259 | ![](../images/starterkit/led-no-resistor.png) 260 | 261 | LED appears not to work may need resistor 262 | 263 | ### 1-Wire Temperature Sensor 264 | ![](../images/starterkit/digital-temp-sensor.png) 265 | 266 | Not yet supported... help wanted! Ask us 267 | 268 | ### 1-Wire Temperature/Humidity Sensor 269 | ![](../images/starterkit/humidity-temperature-sensor.png) 270 | 271 | Not yet supported... help wanted! Ask us 272 | 273 | ### Rotary Encoder 274 | ![](../images/starterkit/rotary-encoder.png) 275 | 276 | not yet supported... help wanted! Ask us 277 | looking for pulse encoding support 278 | -------------------------------------------------------------------------------- /starterkit/examples/analog-sound-example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gobot.io/x/gobot" 7 | "gobot.io/x/gobot/drivers/aio" 8 | "gobot.io/x/gobot/platforms/firmata" 9 | ) 10 | 11 | func main() { 12 | firmataAdaptor := firmata.NewAdaptor("COM111") 13 | sensor := aio.NewAnalogSensorDriver(firmataAdaptor, "0") 14 | 15 | work := func() { 16 | sensor.On(aio.Data, func(data interface{}) { 17 | sound := data.(int) 18 | sound = sound / 10.0 19 | fmt.Println("sound", sound) 20 | }) 21 | } 22 | 23 | robot := gobot.NewRobot("sensorBot", 24 | []gobot.Connection{firmataAdaptor}, 25 | []gobot.Device{sensor}, 26 | work, 27 | ) 28 | 29 | robot.Start() 30 | } 31 | -------------------------------------------------------------------------------- /starterkit/examples/digital-laser.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "gobot.io/x/gobot" 5 | "gobot.io/x/gobot/drivers/gpio" 6 | "gobot.io/x/gobot/platforms/firmata" 7 | ) 8 | 9 | func main() { 10 | firmataAdaptor := firmata.NewAdaptor("COM111") 11 | laser := gpio.NewLedDriver(firmataAdaptor, "13") 12 | 13 | work := func() { 14 | laser.On() 15 | 16 | } 17 | 18 | robot := gobot.NewRobot("bot", 19 | []gobot.Connection{firmataAdaptor}, 20 | []gobot.Device{laser}, 21 | 22 | work, 23 | ) 24 | 25 | robot.Start() 26 | 27 | } 28 | -------------------------------------------------------------------------------- /starterkit/examples/joystick.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gobot.io/x/gobot" 7 | "gobot.io/x/gobot/drivers/aio" 8 | "gobot.io/x/gobot/drivers/gpio" 9 | "gobot.io/x/gobot/platforms/firmata" 10 | ) 11 | 12 | func main() { 13 | firmataAdaptor := firmata.NewAdaptor("COM43") 14 | xAxis := aio.NewAnalogSensorDriver(firmataAdaptor, "0") 15 | yAxis := aio.NewAnalogSensorDriver(firmataAdaptor, "1") 16 | button := gpio.NewButtonDriver(firmataAdaptor, "13") 17 | 18 | work := func() { 19 | xAxis.On(aio.Data, func(data interface{}) { 20 | xAxis := data.(int) 21 | xAxis = xAxis / 10.0 22 | fmt.Println("x axis", xAxis) 23 | 24 | }) 25 | 26 | yAxis.On(aio.Data, func(data interface{}) { 27 | yAxis := data.(int) 28 | yAxis = yAxis / 10.0 29 | fmt.Println("y axis", yAxis) 30 | 31 | }) 32 | 33 | button.On(gpio.ButtonPush, func(data interface{}) { 34 | fmt.Println("button pressed") 35 | }) 36 | button.On(gpio.ButtonRelease, func(data interface{}) { 37 | fmt.Println("button released") 38 | }) 39 | 40 | } 41 | 42 | robot := gobot.NewRobot("sensorBot", 43 | []gobot.Connection{firmataAdaptor}, 44 | []gobot.Device{xAxis, yAxis, button}, 45 | work, 46 | ) 47 | 48 | robot.Start() 49 | } 50 | --------------------------------------------------------------------------------