Skip to content

Commit

Permalink
Reorganize examples
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbeckler committed Oct 12, 2016
1 parent a954fea commit 80569ec
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 97 deletions.
97 changes: 0 additions & 97 deletions examples/UltrasonicSerial/UltrasonicSerial.ino

This file was deleted.

@@ -0,0 +1,67 @@
// Bricktronics Example: UltrasonicSerialBricktronicsBreakoutBoard
// http://www.wayneandlayne.com/bricktronics
//
// This example uses a LEGO NXT Ultrasonic Sensor. Ultrasonic readings
// are taken every 100 milliseconds, and printed out over the serial console.
// Be sure to set your serial console to 115200 baud. The ultrasonic sensor
// reports the distance to an obstruction in front of the sensor
// (in centimeters). It has a range of 2.5 meters, a resolution of 1 cm, and
// reported accuracy of +/- 3 cm. 255 is sometimes reported as an error state.
//
// This example uses an Ultrasonic Sensor, so it needs more voltage
// than a USB port usually gives. Use an external power supply that
// provides between 7.2 and 9 volts DC. Two options that work really
// well are a 9V wall adapter or a 6xAA battery pack (2.1mm plug).
//
// Hardware used:
// * Wayne and Layne Bricktronics Breakout Board
// https://store.wayneandlayne.com/products/bricktronics-breakout-board.html
// * LEGO NXT Ultrasonic sensor
//
// Software libraries used:
// * Wayne and Layne BricktronicsUltrasonic library
// https://github.com/wayneandlayne/BricktronicsUltrasonic
//
// Written in 2016 by Matthew Beckler and Adam Wolf for Wayne and Layne, LLC
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to the
// public domain worldwide. This software is distributed without any warranty.
// You should have received a copy of the CC0 Public Domain Dedication along
// with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.


// Include the Bricktronics libraries
#include <BricktronicsUltrasonic.h>


// Connect these pins on the Bricktronics Breakout board:
// Pin 1 - Connect to an external power supply between 7.2 and 9 volts DC
// Pin 2 - Connect to Ground
// Pin 3 - Connect to Ground
// Pin 4 - Connect to 5V
// Pin 5 - Connect to any digital pin (sclPin)
// Pin 6 - Connect to any digital pin (sdaPin)
//
// The BricktronicsUltrasonic() arguments are:
// sclPin (pin 5), sdaPin (pin 6)
//
BricktronicsUltrasonic u(8, 12);



void setup()
{
// Be sure to set your serial console to 115200 baud
Serial.begin(115200);

// Initialize the ultrasonic sensor connections
u.begin();
}


void loop()
{
Serial.println(u.getDistance());
delay(100);
}

@@ -0,0 +1,60 @@
// Bricktronics Example: UltrasonicSerialBricktronicsMegashield
// http://www.wayneandlayne.com/bricktronics
//
// This example uses a LEGO NXT Ultrasonic Sensor. Ultrasonic readings
// are taken every 100 milliseconds, and printed out over the serial console.
// Be sure to set your serial console to 115200 baud. The ultrasonic sensor
// reports the distance to an obstruction in front of the sensor
// (in centimeters). It has a range of 2.5 meters, a resolution of 1 cm, and
// reported accuracy of +/- 3 cm. 255 is sometimes reported as an error state.
//
// This example uses an Ultrasonic Sensor, so it needs more voltage
// than a USB port usually gives. Use an external power supply that
// provides between 7.2 and 9 volts DC. Two options that work really
// well are a 9V wall adapter or a 6xAA battery pack (2.1mm plug).
//
// Hardware used:
// * Wayne and Layne Bricktronics Megashield
// https://store.wayneandlayne.com/products/bricktronics-megashield-kit.html
// * LEGO NXT Ultrasonic sensor
//
// Software libraries used:
// * Wayne and Layne BricktronicsUltrasonic library
// https://github.com/wayneandlayne/BricktronicsUltrasonic
// * Wayne and Layne BricktronicsMegashield library
// https://github.com/wayneandlayne/BricktronicsMegashield
//
// Written in 2016 by Matthew Beckler and Adam Wolf for Wayne and Layne, LLC
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to the
// public domain worldwide. This software is distributed without any warranty.
// You should have received a copy of the CC0 Public Domain Dedication along
// with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.


// Include the Bricktronics libraries
#include <BricktronicsMegashield.h>
#include <BricktronicsUltrasonic.h>


// Select the sensor port for the sensor (SENSOR_1 through SENSOR_4) below.
// Use the jumpers to connect pins 1-2 and 4-5 for the ultrasonic sensor.
BricktronicsUltrasonic u(BricktronicsMegashield::SENSOR_4);


void setup()
{
// Be sure to set your serial console to 115200 baud
Serial.begin(115200);

// Initialize the ultrasonic sensor connections
u.begin();
}


void loop()
{
Serial.println(u.getDistance());
delay(100);
}

@@ -0,0 +1,63 @@
// Bricktronics Example: UltrasonicSerialBricktronicsShield
// http://www.wayneandlayne.com/bricktronics
//
// This example uses a LEGO NXT Ultrasonic Sensor. Ultrasonic readings
// are taken every 100 milliseconds, and printed out over the serial console.
// Be sure to set your serial console to 115200 baud. The ultrasonic sensor
// reports the distance to an obstruction in front of the sensor
// (in centimeters). It has a range of 2.5 meters, a resolution of 1 cm, and
// reported accuracy of +/- 3 cm. 255 is sometimes reported as an error state.
//
// This example uses an Ultrasonic Sensor, so it needs more voltage
// than a USB port usually gives. Use an external power supply that
// provides between 7.2 and 9 volts DC. Two options that work really
// well are a 9V wall adapter or a 6xAA battery pack (2.1mm plug).
//
// Hardware used:
// * Wayne and Layne Bricktronics Shield
// https://store.wayneandlayne.com/products/bricktronics-shield-kit.html
// * LEGO NXT Ultrasonic sensor
//
// Software libraries used:
// * Wayne and Layne BricktronicsUltrasonic library
// https://github.com/wayneandlayne/BricktronicsUltrasonic
// * Wayne and Layne BricktronicsShield library
// https://github.com/wayneandlayne/BricktronicsShield
//
// Written in 2016 by Matthew Beckler and Adam Wolf for Wayne and Layne, LLC
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to the
// public domain worldwide. This software is distributed without any warranty.
// You should have received a copy of the CC0 Public Domain Dedication along
// with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.


// Include the Bricktronics libraries
#include <BricktronicsShield.h>
#include <BricktronicsUltrasonic.h>


// Select the sensor port for the sensor (SENSOR_3 or SENSOR_4) below.
// Use the jumpers to connect pins 1-2 and 4-5 for the ultrasonic sensor.
BricktronicsUltrasonic u(BricktronicsShield::SENSOR_4);


void setup()
{
// Be sure to set your serial console to 115200 baud
Serial.begin(115200);

// Initialize the Bricktronics Shield
BricktronicsShield::begin();

// Initialize the ultrasonic sensor connections
u.begin();
}


void loop()
{
Serial.println(u.getDistance());
delay(100);
}

23 changes: 23 additions & 0 deletions examples/test_compile.sh
@@ -0,0 +1,23 @@
#!/bin/bash

if [ -z "$ARDUINO" ]; then
echo "Need to set ARDUINO envvar to your arduino binary"
echo "You can use something like this:"
echo " ARDUINO=/path/to/arduino $0"
exit 1
fi

PLATFORMS="arduino:avr:uno arduino:avr:mega:cpu=atmega2560"

for ino in `find $1 | grep '\.ino$'`; do
echo "--------------------------------------------------------------------------------"
for platform in $PLATFORMS; do
echo "$ino - $platform"
echo ""
$ARDUINO --verify --board $platform $ino || exit $?
done
done

echo "--------------------------------------------------------------------------------"
echo "All examples compiled for all platforms, great work."

0 comments on commit 80569ec

Please sign in to comment.