13
SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LEDs 4 push bottons 4 1 Kohm resistances 4 220 ohm resistances Jumpers MAKE SURE YOU’RE CONNECTED TO A NETWORK Click on the wireless network indicator and select the appropriate wireless network. GET YOUR DRAGONBOARD UP TO DATE

SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

SAFESTOP (Instructable)

A step-by-step guide on how to make this project.

THINGS YOU WILL NEED

DragonBoard-410c

Mezzanine Shield

4 LED’s

4 push bottons

4 1 Kohm resistances

4 220 ohm resistances

Jumpers

MAKE SURE YOU’RE CONNECTED TO A NETWORK

Click on the wireless network indicator and select the appropriate wireless network.

GET YOUR DRAGONBOARD UP TO DATE

Page 2: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

To install the new libraries and software, you will have to open a terminal window, which

is located in Start -> System Tools -> LXTerminal (or UXTerm, or XTerm).

Then type this code (without the $ sign):

$ sudo apt-get update

$ sudo apt-get upgrade

$ sudo apt-get dist-upgrade

INSTALL EXTRA TOOL PACKAGES

In order to use the IDE, we’ll install the Debian packages for the standard Linux

development tools, including the Arduino toolchain.

$ sudo apt-get install arduino-mk arduino git build-essential autoconf libtool swig3.0

python-dev nodejs-dev cmake pkg-config libpcre3-dev

CONFIGURE THE SOFTWARE

This is to fetch the 96boards-tools package and install the provided configuration files:

$ sudo adduser linaro i2c # Allow the normal user to perform i2c operations

$ git clone https://github.com/96boards/96boards-tools

$ sudo cp 96boards-tools/70-96boards-common.rules /etc/udev/rules.d/

Now you need to edit/create a shell script in /etc/profile.d the shell script file name is:

96boards-sensors.sh and it might already exist, or it might not.

Then type this code:

$vim /etc/profile.d/96boards-sensors.sh

export JAVA_TOOL_OPTIONS="-Dgnu.io.rxtx.SerialPorts=/dev/tty96B0"

export MONITOR_PORT=/dev/tty96B0

export PYTHONPATH="$PYTHONPATH:/usr/local/lib/python2.7/site-packages"

Save and exit the editor

Copy this file one other place on the file system

$ sudo cp /etc/profile.d/96boards-sensors.sh /etc/X11/Xsession.d/96boards-sensors

Now reboot the system to pick up all the changes

$ sudo reboot

Page 3: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

Once you are back from the reboot, the Arduino IDE should be installed now. Check on the

‘Start’ button (lower left corner of the desktop), then “Programming” tab, and click on the

Arduino IDE.

And now you have to set everything like this on the Arduino IDE:

Check the Tools menu option.

Tools->Board should be set to Arduino Uno

Tools->Serial Port should be set to /dev/tty96B0

Tools->Programmer should be set to AVRISP mkII or AVR ISP

With all these steps you are now ready to program on Arduino, if you want to test it out,

you can click on File->Examples->Basics->Blink option

You should be able to compile it and upload it without any problems on the Mezzanine

Shield.

ARDUINO CODE

This will be the code used on the project. The codes simulates a situation where if a car

arrives first to the stop sign, the other 3 cars coming on the other sides will be warned with

a LED light that a car is near to cross the street so they have to take more precautions. If

many cars arrive at the same time, the first one that arrived will be the first to cross, then

the second one and so on.

const int buttonPin1 = 2; // the number of the pushbutton pin

const int buttonPin2 = 3;

const int buttonPin3 = 4;

const int buttonPin4 = 5;

const int ledPin1 = 8; // the number of the LED pin

const int ledPin2 = 9;

const int ledPin3 = 10;

const int ledPin4 = 11;

// variables will change:

int buttonState1 = 0; // variable for reading the pushbutton status

int buttonState2 = 0;

Page 4: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

int buttonState3 = 0;

int buttonState4 = 0;

void setup() {

// initialize the LED pin as an output:

pinMode(ledPin1, OUTPUT);

pinMode(ledPin2, OUTPUT);

pinMode(ledPin3, OUTPUT);

pinMode(ledPin4, OUTPUT);

// initialize the pushbutton pin as an input:

pinMode(buttonPin1, INPUT);

pinMode(buttonPin2, INPUT);

pinMode(buttonPin3, INPUT);

pinMode(buttonPin4, INPUT);

}

void loop() {

// read the state of the pushbutton value:

buttonState1 = digitalRead(buttonPin1);

buttonState2 = digitalRead(buttonPin2);

buttonState3 = digitalRead(buttonPin3);

buttonState4 = digitalRead(buttonPin4);

// check if the pushbutton is pressed.

// if it is, the buttonState is HIGH:

if (buttonState1 == HIGH && buttonState2 == LOW && buttonState3 == LOW &&

buttonState4 == LOW) {

// turn LED on:

Page 5: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

digitalWrite(ledPin1, LOW);

digitalWrite(ledPin2, HIGH);

digitalWrite(ledPin3, HIGH);

digitalWrite(ledPin4, HIGH);

delay(2000);

}

else if (buttonState1 == LOW && buttonState2 == HIGH && buttonState3 == LOW &&

buttonState4 == LOW) {

// turn LED on:

digitalWrite(ledPin1, HIGH);

digitalWrite(ledPin2, LOW);

digitalWrite(ledPin3, HIGH);

digitalWrite(ledPin4, HIGH);

delay(2000);

}

else if (buttonState1 == LOW && buttonState2 == LOW && buttonState3 == HIGH &&

buttonState4 == LOW) {

// turn LED on:

digitalWrite(ledPin1, HIGH);

digitalWrite(ledPin2, HIGH);

digitalWrite(ledPin3, LOW);

digitalWrite(ledPin4, HIGH);

delay(2000);

}

else if (buttonState1 == LOW && buttonState2 == LOW && buttonState3 == LOW &&

buttonState4 == HIGH) {

// turn LED on:

digitalWrite(ledPin1, HIGH);

digitalWrite(ledPin2, HIGH);

Page 6: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

digitalWrite(ledPin3, HIGH);

digitalWrite(ledPin4, LOW);

delay(2000);

}

else if (buttonState1 == HIGH && buttonState2 == HIGH && buttonState3 == LOW &&

buttonState4 == LOW) {

// turn LED on:

digitalWrite(ledPin1, LOW);

digitalWrite(ledPin2, HIGH);

digitalWrite(ledPin3, HIGH);

digitalWrite(ledPin4, HIGH);

delay(1000);

}

else if (buttonState1 == LOW && buttonState2 == HIGH && buttonState3 == HIGH &&

buttonState4 == LOW) {

// turn LED on:

digitalWrite(ledPin1, HIGH);

digitalWrite(ledPin2, LOW);

digitalWrite(ledPin3, HIGH);

digitalWrite(ledPin4, HIGH);

delay(1000);

}

else if (buttonState1 == LOW && buttonState2 == LOW && buttonState3 == HIGH &&

buttonState4 == HIGH) {

// turn LED on:

digitalWrite(ledPin1, HIGH);

Page 7: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

digitalWrite(ledPin2, HIGH);

digitalWrite(ledPin3, LOW);

digitalWrite(ledPin4, HIGH);

delay(1000);

}

else if (buttonState1 == HIGH && buttonState2 == LOW && buttonState3 == LOW &&

buttonState4 == HIGH) {

// turn LED on:

digitalWrite(ledPin1, HIGH);

digitalWrite(ledPin2, HIGH);

digitalWrite(ledPin3, HIGH);

digitalWrite(ledPin4, LOW);

delay(1000);

}

else if (buttonState1 == HIGH && buttonState2 == HIGH && buttonState3 == HIGH

&& buttonState4 == LOW) {

// turn LED on:

digitalWrite(ledPin1, LOW);

digitalWrite(ledPin2, HIGH);

digitalWrite(ledPin3, HIGH);

digitalWrite(ledPin4, HIGH);

delay(1000);

}

else if (buttonState1 == LOW && buttonState2 == HIGH && buttonState3 == HIGH &&

buttonState4 == HIGH) {

Page 8: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

// turn LED on:

digitalWrite(ledPin1, HIGH);

digitalWrite(ledPin2, LOW);

digitalWrite(ledPin3, HIGH);

digitalWrite(ledPin4, HIGH);

delay(1000);

}

else if (buttonState1 == HIGH && buttonState2 == LOW && buttonState3 == HIGH &&

buttonState4 == HIGH) {

// turn LED on:

digitalWrite(ledPin1, HIGH);

digitalWrite(ledPin2, HIGH);

digitalWrite(ledPin3, LOW);

digitalWrite(ledPin4, HIGH);

delay(1000);

}

else if (buttonState1 == HIGH && buttonState2 == HIGH && buttonState3 == LOW &&

buttonState4 == HIGH) {

// turn LED on:

digitalWrite(ledPin1, HIGH);

digitalWrite(ledPin2, HIGH);

digitalWrite(ledPin3, HIGH);

digitalWrite(ledPin4, LOW);

delay(1000);

}

else {

// turn LED on:

Page 9: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

digitalWrite(ledPin1, LOW);

digitalWrite(ledPin2, LOW);

digitalWrite(ledPin3, LOW);

digitalWrite(ledPin4, LOW);

}

}

CIRCUIT

This is what the circuit will look like

Tip: if you have problems to see the connections, you can check the pins used in the code)

Page 10: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

MAKING THE MODEL

For this project we used SolidWorks to create a template of the model to cut it with a laser

machine cutter. You are free to decide how to make the model.

Page 11: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

After cutting all the templates, the result was ready to just be assembly and painted.

Page 12: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1
Page 13: SAFESTOP (Instructable)SAFESTOP (Instructable) A step-by-step guide on how to make this project. THINGS YOU WILL NEED DragonBoard-410c Mezzanine Shield 4 LED’s 4 push bottons 4 1

This was the final result (with the built-in circuit)