UWSA responsive environments workshop

a platform for discussions & questions

Notes

the insult machine - electronic brick version

how it works:

on the first “insult machine”, using the potentiometer (Analog 5), the user scrolls through a list of potential 2-line insults on the 16*2 LCD (BUS 2).

the button (Analog 4) is pressed once to choose an insult.

“You have chosen insult x!”

“Tilt to send”

the button (Analog 4) is pressed again and the insult is “sent” (Digital 9 - comOut) to the 2nd “insult machine” (Digital 8 - comIn)…

“INCOMING INSULT!” flashes on the LCD (BUS 2) of the second machine, interrupting the 2nd user.

the chosen insult is then displayed on the LCD (BUS 2) of 2nd machine followed by computer laughter (HA HA HA HA in random positions alternating between the first and second row of the LCD).

both users return to scrolling through their respective insults using the potentiometers (Analog 5).

i uploaded a slight variation to each machine: machine one has 10 possible send insults and ten possible receive insults, machine 2’s libraries are reversed so the insult you receive is not in the list you have been scrolling through). i change the comebackStrings[] called up in the code and upload to the 2nd machine.

two "insult machines" connectedone "insult machine"

// include the lcd library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(10, 11, 12, 13, 14, 15, 16);

int tilt = 4;
int button = 4;

int comOut = 9; //initiates comunication ports at pins 8(Out) and 9(In)
int comIn = 8;

int Rot = 5;

int valRot = 0;
int valTilt = 0;
int valButton = 0;
int valNewButton = 0;
int valComeback = 0;
int valInsult = 1;
int valIn = LOW;
int comebackIn = 0;

// these constants won’t change.  But you can change the size of
// your LCD using them:
const int numRows = 2;
const int numCols = 16;

char* comebackStrings[]={“”, “Wheel turning…”, “Your village is”,
“You stand close”, “Are your parents”, “You MUST use…”, “No vaccine…”,
“Useless as…”, “No prejudice…”, “Bus leaving…”, “May your soul…”};

char* comebackStrings2[]={“”, “…hamster dead!”, “missing an idiot”,
“I hear the ocean”, “…siblings?!?”, “…birth control”, “..against stupid”,
“Popes testicles”, “…hate everyone”, “pls be under it”, “…rest in piss”};

char* comebackStrings3[]={“”, “Boring as a…”, “I dont date…”,
“Brains of 3 men”, “Does fuzzy logic”, “A closed mouth”, “Assasins do it”,
“Your gene pool”, “Death is…”, “Laugh last…”, “NO shampoo!”};

char* comebackStrings4[]={“”, “pneumatic drill”, “…other species”,
”..the 3 stooges!”, “…tickle?”, “gathers no foot”, “…from behind”,
“could use Cl2”, “hereditary”, “…think slowest”, “REAL POO!”};

void setup()
{
pinMode(comOut, OUTPUT); 
digitalWrite(comOut, LOW);
pinMode(comIn, INPUT);
lcd.begin(numRows, numCols);
Serial.begin(9600);
}

void loop()
{
lcd.clear();
delay(100);
readRot();
printComeback(); 
delay(10);
}

void readRot(){
valRot = analogRead(Rot);
delay(10);
valRot = map(valRot, 0, 1023, 1, 10);
delay(10);
checkValIn();
}

void checkButton(){
if (valButton != 1){
valButton = analogRead(button);
delay(10);
valButton = map(valButton, 0, 1023, 0, 1);
}
delay(10);
if (valButton == HIGH){
choseComeback();
}
}

void checkTilt(){
while (valTilt != 1){
valTilt = analogRead(tilt);
delay(10);
valTilt = map(valTilt, 0, 1023, 0, 1);
delay(10);
}
tiltComeback();
}

void checkValIn(){
valIn = digitalRead(comIn);
delay(10);
if (valIn == HIGH){
Serial.println(“ValIn HIGH”);
insulted();
valIn = LOW;
Serial.println(“ValIn LOW”);
}
}

void recValIn(){ 
valIn = LOW;
while (valIn == LOW){
valIn = digitalRead(comIn);
delay(10);
}
comebackIn = 0;
while (valIn != LOW){
comebackIn++;
delay(100);
valIn = digitalRead(comIn);
}
comebackIn = (comebackIn - 1);
}

void printComeback(){
while (valComeback == 0){
readRot();
lcd.clear();
lcd.print(comebackStrings[valRot]);
checkValIn();
checkButton();
delay(500);
lcd.setCursor(0, 1);
lcd.print(comebackStrings2[valRot]);
checkValIn();
checkButton();
delay(500);
checkValIn();
checkButton();
delay(500);
checkValIn();
checkButton();
delay(500);
}
}

void choseComeback(){
valComeback = valRot;
lcd.clear();
lcd.print(“You chose…”);
delay(500);
lcd.setCursor(0, 1);
lcd.print(“Insult “);
lcd.print(valRot);
lcd.print(“!”);
delay(1000);
lcd.clear();
lcd.print(“TILT to send”);
valTilt = 0;
checkTilt();
}

void tiltComeback(){
lcd.clear();
lcd.print(“TILT!”);
delay(1000);
lcd.clear();
digitalWrite(comOut, HIGH);
while (valIn != HIGH){
valIn = digitalRead(comIn);
delay(10);
}
Serial.println(“ValIn HIGH”);
digitalWrite(comOut, LOW);
Serial.println(“ComOut LOW”);
delay(1000);
digitalWrite(comOut, HIGH);
Serial.println(“ComOut HIGH”);
for (int a=0; a <= valComeback; a++){
delay(100);}
digitalWrite(comOut, LOW);
Serial.println(“ComOut LOW”);
delay(10);  
valTilt = 0;
valComeback = 0;
valButton = 0;
}

void insulted(){
digitalWrite(comOut, HIGH);
Serial.println(“ComOut HIGH”);
delay(10);
digitalWrite(comOut, LOW);
Serial.println(“ComOut LOW”);
valIn = LOW;
Serial.println(“ValIn LOW”);
recValIn();
valInsult = constrain(comebackIn, 1, 10);
lcd.clear();
lcd.print(“INCOMING INSULT!”);
delay(500);
lcd.setCursor(0, 1);
lcd.print(“INCOMING INSULT!”);
delay(500);
lcd.clear();
delay(500);
lcd.print(“INCOMING INSULT!”);
delay(500);
lcd.setCursor(0, 1);
lcd.print(“INCOMING INSULT!”);
delay(500);
lcd.clear();
lcd.print(comebackStrings3[valInsult]);
delay(500);
lcd.setCursor(0, 1);
lcd.print(comebackStrings4[valInsult]);
delay(5000);
for (int count = 0; count <= 5; count++){
lcd.clear();
lcd.setCursor(random(15), 0);
lcd.print(“HA”);
delay(200);
lcd.setCursor(random(15), 1);
lcd.print(“HA”);
delay(200);
lcd.clear();
}
}


Filed under arduino electronic bricks communication

0 notes

multiplexing!

hi all (especially Brandon)

i bought a couple of multiplexers (16ch analog, #4607 from creatron)…and got one working!

here is a diagram, a picture and the code to blink an LED on pin y8 (pin 23 on the multiplexer).

s

here is a diagram and a pic and the code:


/*
16 Channel Analog Extender for Arduino
*/

// Set Analog I/O pin to use for reading channel values from multiplexer.
int ComIOpin = 6;  // HEF4067BP(X)(ICpin-01)

// Set which pins tell the multiplexer which input to read from.
int DpinA0 = 10;  // HEF4067BP Address Input A0 (A)(ICpin-10)
int DpinA1 = 11;  // HEF4067BP Address Input A1 (B)(ICpin-11)
int DpinA2 = 12;  // HEF4067BP Address Input A2 (C)(ICpin-14)
int DpinA3 = 13;  // HEF4067BP Address Input A3 (D)(ICpin-13)

void setup() {

// Set the digital pins to outputs.
pinMode(DpinA0, OUTPUT);  // HEF4067BP Address Input A = pin10
pinMode(DpinA1, OUTPUT);  // HEF4067BP Address Input B = pin11
pinMode(DpinA2, OUTPUT);  // HEF4067BP Address Input C = pin12
pinMode(DpinA3, OUTPUT);  // HEF4067BP Address Input D = pin13


pinMode(comIOpin, OUTPUT);

Serial.begin(9600); // Set Serial COM

}

void loop() {
digitalWrite(DpinA0, LOW);
digitalWrite(DpinA1, LOW);
digitalWrite(DpinA2, LOW);
digitalWrite(DpinA3, HIGH);
analogWrite(ComIOpin, 255;
delay(500);
analogWrite(ComIOpin, 0);
delay(500);
}

Filed under arduino question multiplexer

0 notes

how to get started

a) Download Arduino software:
www.arduino.cc

b) Download USB driver:
http://www.ftdichip.com/Drivers/VCP.htm
[the Arduino board has an ‘FTDI’-type chip that provides USB connection for your laptop. Download the ‘Virtual COM’ FTDI driver shown on the site, corresponding to your laptop operating system. ]

c) Download MaxMSP ‘free trial’ software:
http://cycling74.com/downloads/max5

d) Download the ‘Digital Cookbook’ reference guide for the ‘Electronic Brick’ extension kit that will be used for hands-on demonstrations during the workshops. We will use a number of code setups within this: http://www.seeedstudio.com/depot/images/product/Electronic%20Bricks%20Vol1.1.pdf

0 notes

What Questions do you Have?

Hey folks,

Brandon here. Just wanted to put up a post now that the weekend is over and open the floor to questions. I won’t be checking too frequently (read: once or twice a week) but I am more than willing to be your local source for Arduino help since Pieter will be gone by the end of the week.

Feel free to post any questions you’ve got that the arduino website can’t answer, or any questions on programming in general.

Ask away!