Show Posts
Pages: [1] 2
1  Using Arduino / Installation & Troubleshooting / Re: Problem with Arduino Uno Problem solved on: September 05, 2011, 01:40:27 pm
hi All,
just to say I solved this issue. Spent hors changing the delay in both Arduino and Processing and also the Baud rate. I found the right combination that works. I can post it here if anyone would like to se the solution.

best,

Frank
2  Using Arduino / Installation & Troubleshooting / Re: Problem with Arduino Uno on: August 25, 2011, 01:28:52 pm
Hi,
ok will have a look at that, but do you think that might be the issue if the code is ok?

Thanks,

F
3  Using Arduino / Installation & Troubleshooting / Re: Problem with Arduino Uno on: August 25, 2011, 11:40:25 am
Hi Robillaart, thanks wasn't quite sure how to do that.  smiley F
Code:
/*
 * PIR sensor tester
 */
 
int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;   // variable for reading the pin status
float startms = millis();
 
void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
 
  Serial.begin(9600);
  digitalWrite(ledPin, 0);
}

void loopTEST(){
float currentms = millis() - startms;

if (currentms > 500){
 
  val = !val;
  digitalWrite(ledPin, val);
  startms = millis();
}
}
 
void loop(){
  delay(100);
  val = digitalRead(inputPin);  // read input value
  digitalWrite(ledPin, val);  // turn LED ON or OFF
 
  // Serial.print(val) BUT SEE BELOW. DON'T UNCOMMENT!!!!
    if (val == 1){
   
 
   Serial.print(1, BYTE); // There is a potential reason for this verbose version:--
   
   
    }else{
     Serial.print(0, BYTE);
    }
}


Processing

import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
//name it
Minim minim;
//Name the track
AudioPlayer AllahuAkbarAdan;
boolean flag = false;
//Processing:

import processing.serial.*;

Serial port;
String inputString;
float inputConvertedToFloat;

float minimumDelayUntilStasis = 1000;
float startOfMillisecondCount = millis();
float startms = millis();
boolean val = false;
boolean hasTimedOut = false;

boolean soundSwitch = true;
int previousInByte = 1; // 1 means NOT moving

void setup(){
 println(Serial.list());
 port = new Serial(this, Serial.list()[0], 9600); //
may have to change
frameRate(200);
 ///////////////
 
  minim = new Minim (this);
AllahuAkbarAdan = minim.loadFile ("AllahuAkbarAdan.mp3");
 AllahuAkbarAdan. loop();
AllahuAkbarAdan.mute();
 
  /////////////////////
}


void draw() {
 //lully.setVolume(0.00001);
 
 if (port.available() > 0) {
 int inByte = port.readChar(); // N.B. Oddly, a zero reading means there IS motion
 
 print(inByte);
 if (inByte == 0){
 if (previousInByte == 1){
   print("change to zero");
   if (soundSwitch == true){
   AllahuAkbarAdan.unmute();
   }else{
   AllahuAkbarAdan.mute();
   }
   soundSwitch = !soundSwitch;
 }
 }
 previousInByte = inByte;
 }
}

void drawTestingMINIM(){
float currentms = millis() - startms;

if (currentms > 2000){
 
  val = !val;
  if (val == true){
AllahuAkbarAdan.unmute();
  }else{
AllahuAkbarAdan.mute();
  }
  startms = millis();
}
}
4  Using Arduino / Installation & Troubleshooting / Re: Problem with Arduino Uno on: August 25, 2011, 10:28:13 am
Hi Robtillaart,
I've tested all the UNOs with the blink sketch all work as they should.
Hesr is my Arduino code and I have included my Processing code as the sketch outputs a sound in Processing. All of this works perfectly with the ATMEGA 328
Link to motion sensor/////http://www.skpang.co.uk/catalog/pir-motion-sensor-p-796.html

Many thanks for your attention.  Frank

Arduino

 
/*
 * PIR sensor tester
 */
 
int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;   // variable for reading the pin status
float startms = millis();
 
void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
 
  Serial.begin(9600);
  digitalWrite(ledPin, 0);
}

void loopTEST(){
float currentms = millis() - startms;

if (currentms > 500){
 
  val = !val;
  digitalWrite(ledPin, val);
  startms = millis();
}
}
 
void loop(){
  delay(100);
  val = digitalRead(inputPin);  // read input value
  digitalWrite(ledPin, val);  // turn LED ON or OFF
 
  // Serial.print(val) BUT SEE BELOW. DON'T UNCOMMENT!!!!
    if (val == 1){
   
 
   Serial.print(1, BYTE); // There is a potential reason for this verbose version:--
   
   
    }else{
     Serial.print(0, BYTE);
    }
}


Processing

import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
//name it
Minim minim;
//Name the track
AudioPlayer AllahuAkbarAdan;
boolean flag = false;
//Processing:

import processing.serial.*;

Serial port;
String inputString;
float inputConvertedToFloat;

float minimumDelayUntilStasis = 1000;
float startOfMillisecondCount = millis();
float startms = millis();
boolean val = false;
boolean hasTimedOut = false;

boolean soundSwitch = true;
int previousInByte = 1; // 1 means NOT moving

void setup(){
 println(Serial.list());
 port = new Serial(this, Serial.list()[0], 9600); //
  • may have to change
frameRate(200);
 ///////////////
 
  minim = new Minim (this);
AllahuAkbarAdan = minim.loadFile ("AllahuAkbarAdan.mp3");
 AllahuAkbarAdan. loop();
AllahuAkbarAdan.mute();
 
  /////////////////////
}


void draw() {
 //lully.setVolume(0.00001);
 
 if (port.available() > 0) {
 int inByte = port.readChar(); // N.B. Oddly, a zero reading means there IS motion
 
 print(inByte);
 if (inByte == 0){
 if (previousInByte == 1){
   print("change to zero");
   if (soundSwitch == true){
   AllahuAkbarAdan.unmute();
   }else{
   AllahuAkbarAdan.mute();
   }
   soundSwitch = !soundSwitch;
 }
 }
 previousInByte = inByte;
 }
}

void drawTestingMINIM(){
float currentms = millis() - startms;

if (currentms > 2000){
 
  val = !val;
  if (val == true){
AllahuAkbarAdan.unmute();
  }else{
AllahuAkbarAdan.mute();
  }
  startms = millis();
}
}
5  Using Arduino / Installation & Troubleshooting / Problem with Arduino Uno on: August 25, 2011, 07:57:14 am
Hi All,
I have just purchased 3 new Uno boards which it says are the upgrades to the ATMEGA 328. I have been using an ATMEGA 328 along with a PIR motion detector and it works perfectly, I have 4 of these PIRS and tested all with the ATMEGA 328 and they work fine. Problem comes when I try to run the PIR with UNO, the sensors become extremely unstable and of no use for my task. Of course I have checked serial ports and boards etc, the wiring and code are both exactly the same for the ATMEGA 328 and UNO. I should make it clear that I'm running one sensor with one Arduino at a time.
Anyone else experienced similar problems - I'd be so happy for a solution.

Many thanks,

Frank
6  Using Arduino / Project Guidance / Re: Processing and Minim with some pre recorded sound - and Arduino sensors on: June 23, 2011, 04:19:56 am
Sure I understand your point, thanks. Do you have any advice on which sensor is best to use and how to set it up? I have never tried to do anything like this before but have seen similar type installations in galleries. i am still a newbie to both Arduino and Processing.

TIA,

Frank
7  Using Arduino / Project Guidance / Re: Processing and Minim with some pre recorded sound - and Arduino sensors on: June 19, 2011, 05:59:58 am
Hi I have already considered this and it doesn't matter if one or all three sound sources are playing at the same time, any other thoughts appreciated.

TIA,

Frank
8  Using Arduino / Project Guidance / Processing and Minim with some pre recorded sound - and Arduino sensors on: June 18, 2011, 07:21:29 am
Hi All,
I'm about to start a new project and would like a quick ok or other wise on the feasibility of my idea.
I want to use Processing and Minim with some pre recorded sound - straightforward I know but I also want to use Arduino (pressure sensitive pads, sonar or IR sensors) not yet decided which is best for the purpose.
The idea is that as the spectator walks past a wall mounted object the sound is generated, if they move on the sound stops. There will be three of these in a row approx 1m apart and I want to have the first one go off before the second one comes on and so on....
Has any one any experience of this and if so I would appreciate your comments code tips and any pitfalls.
The second part will involve the participant interacting with objects in a room using the same technology.

Any thoughts, hints etc will be much appreciated.

TIA,

Frank
9  Using Arduino / Programming Questions / Re: Newbie needs help with coding a chase sequence on: February 25, 2011, 12:08:31 pm
Hi all,
I have this code that uses a pushbutton to start a chase and I want to alter the end from all the LEDS going out at once to going off one at a time in a random manner. Could someone please help me with the code or tell me what I need to write in order to make this happen.

// A chase controlled by a button

int Button=2; //button assigned to pin 2
int timer = 100; // The higher the number, the slower the timing.
int ledPins[] = {
3,4,5,6,7,8,9,10 }; // an array of pin numbers to which LEDs are attached
int pinCount = 8; // the number of pins (i.e. the length of the array)

void setup()
{
  Serial.begin(9600);
pinMode(Button, INPUT);
int thisPin;
// the array elements are numbered from 0 to (pinCount - 1).
// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < pinCount; thisPin++)
 {
pinMode(ledPins[thisPin], OUTPUT);
}
}
//turn LEDS on
void loop() {
while (digitalRead(Button)==HIGH);
{
//delay (10);
  Serial.println("LOW");

}

while (digitalRead(Button)==LOW)
{
  Serial.println("HIGH");
for (int thisPin = 0; thisPin < pinCount; thisPin++)
{
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);
}

for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--)
{
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);
}
}
}

I thought it might be something like this but can't seem to piece it together to get it to work.

// switch them randomly on and off
int someNumber = 22;
for (int i = 0; i < someNumber; i++)
{
 int thisPin = random(3,10);
 if (random(1) == 1){ // random(1) returns 0 or 1, I hope
  digitalWrite(ledPins[thisPin], HIGH);
 }
 else
 {
  digitalWrite(ledPins[thisPin], LOW);
 }
}
// Finally, switch them all off
for (int thisPin = 0; thisPin < pinCount; thisPin++)
 {
 digitalWrite(ledPins[thisPin], LOW);
}


Any help much appreciated.

many thanks,

Frank
10  Using Arduino / Programming Questions / Newbie needs help with coding a chase sequence on: February 25, 2011, 10:22:08 am
Hi all,
I have this code that uses a pushbutton to start a chase and I want to alter the end from all the LEDS going out at once to going off one at a time in a random manner. Could someone please help me with the code or tell me what I need to write in order to make this happen.

// A chase controlled by a button

int Button=2; //button assigned to pin 2
int timer = 100; // The higher the number, the slower the timing.
int ledPins[] = {
3,4,5,6,7,8,9,10 }; // an array of pin numbers to which LEDs are attached
int pinCount = 8; // the number of pins (i.e. the length of the array)

void setup() {
  Serial.begin(9600);
pinMode(Button, INPUT);
int thisPin;
// the array elements are numbered from 0 to (pinCount - 1).
// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}
//turn LEDS on
void loop() {
while (digitalRead(Button)==HIGH);
{
//delay (10);
  Serial.println("LOW");

}

while (digitalRead(Button)==LOW)
{
  Serial.println("HIGH");
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);
}

for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);
}
}
}

I thought it might be something like this but can't seem to piece it together to get it to work.

// switch them randomly on and off
int someNumber = 22;
for (int i = 0; i < someNumber; i++){
 int thisPin = random(3,10);
 if (random(1) == 1){ // random(1) returns 0 or 1, I hope
  digitalWrite(ledPins[thisPin], HIGH);
 }
 else
 {
  digitalWrite(ledPins[thisPin], LOW);
 }
}
// Finally, switch them all off
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
 digitalWrite(ledPins[thisPin], LOW);
}


Any help much appreciated.

many thanks,

Frank
11  Using Arduino / LEDs and Multiplexing / Newbie LED chase sequence on: February 25, 2011, 05:07:39 am
Hi all,
I have this code that uses a pushbutton to start a chase and I want to alter the end from all the LEDS going out at once to going off one at a time in a random manner. Could someone please give me some code or tell me what I need to write in order to make this happen.

// A chase controlled by a button

int Button=2; //button assigned to pin 2
int timer = 100; // The higher the number, the slower the timing.
int ledPins[] = {
3,4,5,6,7,8,9,10 }; // an array of pin numbers to which LEDs are attached
int pinCount = 8; // the number of pins (i.e. the length of the array)

void setup() {
  Serial.begin(9600);
pinMode(Button, INPUT);
int thisPin;
// the array elements are numbered from 0 to (pinCount - 1).
// use a for loop to initialize each pin as an output:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}
//turn LEDS on
void loop() {
while (digitalRead(Button)==HIGH);
{
//delay (10);
  Serial.println("LOW");

}

while (digitalRead(Button)==LOW)
{
  Serial.println("HIGH");
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);
}

for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
digitalWrite(ledPins[thisPin], LOW);
}
}
}

I thought it might be something like this but can't seem to piece it together to get it to work.

// switch them randomly on and off
int someNumber = 22;
for (int i = 0; i < someNumber; i++){
 int thisPin = random(3,10);
 if (random(1) == 1){ // random(1) returns 0 or 1, I hope
  digitalWrite(ledPins[thisPin], HIGH);
 }
 else
 {
  digitalWrite(ledPins[thisPin], LOW);
 }
}
// Finally, switch them all off
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
 digitalWrite(ledPins[thisPin], LOW);
}


Any help much appreciated.

many thanks,

Frank
12  Using Arduino / Project Guidance / Re: Code problem from a newbie on: February 15, 2011, 02:38:58 pm
Hi, I am so new to this that I don't really understand the answer do you mean I write "turn array on" or something and how do I get it to turn off when the button is "low" is it simply the reverse of this or do I need Arduino syntax (if so iy is precisely this I need help with.

Many thanks,

Frank
13  Using Arduino / Project Guidance / Code problem from a newbie on: February 15, 2011, 02:04:06 pm
Hi Folks,
I would appreciate some help with this problem. I keep getting the message "expected primary-expression before } token"
 I have tried to combine two codes - one which creates an array to make a chase effect with leds and one which uses a button to control an led however i cannot make the button start and end the chase. What am I doing wrong?
I should also say that each code works perfectly before I combine them

Any help most welcome.

Many thanks,

Frank
 

/*
 The circuit:
 * LEDs from pins 2 through 9 to ground
 
 created 2006
 by David A. Mellis
 modified 5 Jul 2009
 by Tom Igoe

This example code is in the public domain.
 
 http://www.arduino.cc/en/Tutorial/Array
 */
int Button=1; //button assigned to pin 1
int timer = 100;           // The higher the number, the slower the timing.
int ledPins[] = {
  2,3,4,5,6,7,8,9 };       // an array of pin numbers to which LEDs are attached
int pinCount = 8;           // the number of pins (i.e. the length of the array)

void setup() {
  pinMode(Button, INPUT);
  int thisPin;
  // the array elements are numbered from 0 to (pinCount - 1).
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 0; thisPin < pinCount; thisPin++)  {
    pinMode(ledPins[thisPin], OUTPUT);     
  }
}

void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], HIGH);   
    delay(timer);                 
    // turn the pin off:
    {
    digitalWrite(ledPins[thisPin], LOW);   
    }
while (digitalRead(Button)==HIGH)
  }

  // loop from the highest pin to the lowest:
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], LOW);
  }
}
14  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Absolute beginner on: January 09, 2011, 07:36:26 am
Hi folks,
got it solved yesterday and just for general info I used this one
Processing Library: processing-arduino-0017.zip (Updated 22 Sept. 2009)
and it works fine on both my imac and macbook.

Cheers,

Frank
15  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Absolute beginner on: January 08, 2011, 07:57:17 am
Hi Folks,
thanks for all the help andI'm making headway at last. I have another question though. I am trying to use Arduino with Processing and the Arduino site list two types of board see below

Processing Library: processing-arduino-0017.zip (Updated 22 Sept. 2009)
Processing library for arduinoMega: processing-arduinomega.zip (Updated 12 Apr. 2010)
however I have the Uno which is not mentioned here. Any suggestions?

many thanks,

Frank
Pages: [1] 2