Show Posts
Pages: [1] 2
1  Using Arduino / Project Guidance / Re: I cant get the code right on Processing, Help Please on: August 27, 2013, 01:45:18 am
Because i was hoping for somebody more skilled than me in this subject can help me modify it, i dont even know where to start
2  Using Arduino / Project Guidance / Re: I cant get the code right on Processing, Help Please on: August 27, 2013, 01:39:26 am
I didnt write the code so its hard for me to change it, but thank you
3  Using Arduino / Project Guidance / I cant get the code right on Processing, Help Please on: August 27, 2013, 01:19:46 am
Im trying to find away to add a new toggle to control another LED

This is the original website with the project description https://www.sparkfun.com/tutorials/152

This is the processing code

Code:
import oscP5.*;        //  Load OSC P5 library
import netP5.*;        //  Load net P5 library
import processing.serial.*;    //  Load serial library

Serial arduinoPort;        //  Set arduinoPort as serial connection
OscP5 oscP5;            //  Set oscP5 as OSC connection

int oneLED = 0;        //  redLED lets us know if the LED is on or off
int twoLED = 0;        //  redLED lets us know if the LED is on or off
int [] led = new int [2];    //  Array allows us to add more toggle buttons in TouchOSC

void setup() {
  size(100,100);        // Processing screen size
  noStroke();            //  We don’t want an outline or Stroke on our graphics
    oscP5 = new OscP5(this,8000);  // Start oscP5, listening for incoming messages at port 8000
   arduinoPort = new Serial(this, Serial.list()[0], 9600);    // Set arduino to 9600 baud
}

void oscEvent(OscMessage theOscMessage) {   //  This runs whenever there is a new OSC message

    String addr = theOscMessage.addrPattern();  //  Creates a string out of the OSC message
    if(addr.indexOf("/1/toggle") !=-1){   // Filters out any toggle buttons
      int i = int((addr.charAt(9) )) - 0x30;   // returns the ASCII number so convert into a real number by subtracting 0x30
      led[i]  = int(theOscMessage.get(0).floatValue());     //  Puts button value into led[i]
    // Button values can be read by using led[0], led[1], led[2], etc.
     
    }
}

void draw() {
 background(50);        // Sets the background to a dark grey, can be 0-255

   if(led[1] == 0){        //  If led button 1 if off do....
    arduinoPort.write("r");    // Sends the character “r” to Arduino
    oneLED = 0;        // Sets redLED color to 0, can be 0-255
  }
 if(led[1] == 1){        // If led button 1 is ON do...
  arduinoPort.write("R");    // Send the character “R” to Arduino
  oneLED = 255;        // Sets redLED color to 255, can be 0-255
  }
  fill(oneLED,0,0);            // Fill rectangle with redLED amount
   ellipse(50, 50, 50, 50);    // Created an ellipse at 50 pixels from the left...
                // 50 pixels from the top and a width of 50 and height of 50 pixels
               
}

The second LED is called twoLED

The Arduino sketch is ready to go im just stuck on this, any help please smiley
4  Using Arduino / Project Guidance / Re: Room Automation With Adruino on: May 12, 2013, 01:20:03 am
Thank you Terryking, i will look into that
5  Using Arduino / Project Guidance / Room Automation With Adruino on: May 11, 2013, 01:29:28 am
So I would like to control my room with my Arduino Uno. The only problem is that I cant find a way to control the lights in my room without putting in something like a servo to move the switch. I was looking into using a relay but I didn't understand how to do it. Any help please? Thank You smiley
6  Using Arduino / Programming Questions / Re: Wireless Arduino Communication on: January 25, 2013, 12:07:29 pm
Thank you, your info helped out a lot smiley
7  Using Arduino / Programming Questions / Wireless Arduino Communication on: January 25, 2013, 01:55:34 am
I am wondering if i can wirelessly send information through IR sensors. Like the basic ones as in a cheap rc car type of IR

Thank you!
8  Using Arduino / Project Guidance / Re: Serial DC Motor Control on: January 18, 2013, 08:26:39 pm
Thank you, that helped me a lot. I'm going to rewrite the first sketch, and then combine it so it will be more solid
9  Using Arduino / Project Guidance / Serial DC Motor Control on: January 17, 2013, 08:54:06 pm
I need to combine these too code, I tried to but it ended up not working at all. If you would like can you guys guide me on how to combine these code. I'm still a rookie. The codes work perfectly individually.

Code:
int ad=8; 
int cd=7; 
int incom;


void setup(){
  Serial.begin(9600);
}


void loop(){
  if(Serial.available()){
    incom=Serial.read(); 
  }
  switch(incom){
    case'a':
    pinMode(ad,OUTPUT);
    pinMode(cd,OUTPUT);
    digitalWrite(ad,HIGH);
    digitalWrite(cd,LOW);
    Serial.println("FORWARD");
    break;
    case's':
    pinMode(ad,OUTPUT);
    pinMode(cd,OUTPUT);
    digitalWrite(ad,LOW);
    digitalWrite(cd,HIGH);
    Serial.println("REVERSE");
    break;
    case'd':
    pinMode(ad,OUTPUT);
    pinMode(cd,OUTPUT);
    digitalWrite(ad,LOW);
    digitalWrite(cd,LOW);
    Serial.println("BRAKE");
    break;
    case'f':
    pinMode(ad,INPUT);
    pinMode(cd,INPUT);
    Serial.println("FREE-RUN");
    break;
    default:
    Serial.println("Please key in command");
    delay(1000);
    break;
  }
}

And here is the second code set

Code:
int motorPin = 3;
 
void setup()
{
  pinMode(motorPin, OUTPUT);
  Serial.begin(9600);
  while (! Serial);
  Serial.println("Speed 0 to 255");
}
 
 
void loop()
{
  if (Serial.available())
  {
    int speed = Serial.parseInt();
    if (speed >= 0 && speed <= 255)
    {
      analogWrite(motorPin, speed);
    }
  }
}


Please help, i will be really grateful. Thank you smiley-cool

Criss Chicas
10  Using Arduino / Project Guidance / Re: Controlling RGB Lights on: May 27, 2012, 11:45:21 pm
Thanks man, but i want to change the colors so that a variety of colors come up.
11  Using Arduino / Project Guidance / Re: Controlling RGB Lights on: May 27, 2012, 01:46:09 am
I accidentally ran 9v into the Arduino. And it is a strip of RGB leds i can control all with a 9v battery but only the hole thing because it is all connected to each other
12  Using Arduino / Project Guidance / Controlling RGB Lights on: May 26, 2012, 04:55:46 pm
So last time i tried to do this i burnt my Arduino. I have a strip of LED RGB lights that i want to use. They take in 9v battery to light up, but i want my Arduino to control the color changes and i dont understand how to do this. Can anybody help please
13  Using Arduino / Project Guidance / Re: OK i need super good code writers to help me [beginer project] on: June 05, 2011, 02:24:37 pm
Thamkyou so much KE7GKP but it is putting an error when i compile it...... it high lights
Code:
       myservo.write(180);         // send servo to the 180 degree position and stay
and says that "myservo was not declared in this scope"
14  Using Arduino / Project Guidance / OK i need super good code writers to help me [beginer project] on: June 05, 2011, 01:20:59 pm
ok i need to merge two codes together to make one. I need my servo to move 90 degrees when the PIR Sensor is activated. and yea thats about is. so i have these two codes.


This code is for the PIR Sensor. When the sensor is activated it makes a light and oiezo speaker light, and buzz.

/////////////////////////////
//VARS
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;       

//the time when the sensor outputs a low impulse
long unsigned int lowIn;         

//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 5000; 

boolean lockLow = true;
boolean takeLowTime; 

int pirPin = 3;    //the digital pin connected to the PIR sensor's output
int ledPin = 13;


/////////////////////////////
//SETUP
void setup(){
  Serial.begin(9600);
  pinMode(pirPin, INPUT);
  digitalWrite(pirPin, LOW);

  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
      Serial.print(".");
      delay(1000);
      }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);
  }

////////////////////////////
//LOOP
void loop(){

     if(digitalRead(pirPin) == HIGH){
       digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
       if(lockLow){ 
         //makes sure we wait for a transition to LOW before any further output is made:
         lockLow = false;           
         Serial.println("---");
         Serial.print("motion detected at ");
         Serial.print(millis()/1000);
         Serial.println(" sec");
         delay(50);
         }         
         takeLowTime = true;
       }

     if(digitalRead(pirPin) == LOW){       
       digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state

       if(takeLowTime){
        lowIn = millis();          //save the time of the transition from high to LOW
        takeLowTime = false;       //make sure this is only done at the start of a LOW phase
        }
       //if the sensor is low for more than the given pause,
       //we assume that no more motion is going to happen
       if(!lockLow && millis() - lowIn > pause){ 
           //makes sure this block of code is only executed again after
           //a new motion sequence has been detected
           lockLow = true;                       
           Serial.print("motion ended at ");      //output
           Serial.print((millis() - pause)/1000);
           Serial.println(" sec");
           delay(50);
           }
       }
  }



This simply makes the servo move 90 degrees whan power goes throught the arduino

#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
Servo myservo2; // a maximum of eight servo objects can be created
 
int pos = 90;    // variable to store the servo position
 
// set a variable to store the byte sent from the serial port
int incomingByte;
 
void setup() {

  // start sending data at 9600 baud rate
  Serial.begin(9600);
  myservo.attach(9);    // attaches the servo on pin 9 to the servo object
  myservo2.attach(10);  // attaches the servo on pin 10 to the servo object

}
 
void loop() {
  // check that there's something in the serial buffer
  if (Serial.available() > 0) {
    // read the byte and store it in our variable
    // the byte sent is actually an ascii value
    incomingByte = Serial.read();
    // note the upper casing of each letter!
    // each letter turns a motor different way.
   
    // start of left laser sweep, moving left 90 degrees.
    // arrow laser spins and points to left.
    if (incomingByte == 'L') {
    Serial.println(incomingByte);
   
    myservo2.write(180);                         // send servo 2 to the 180 degree position and stay
    for(pos = 180; pos > 90; pos -= 1)  // goes from 90 degrees to 180 degrees
  {     // in steps of 1 degree
    Serial.println(pos);
    myservo.write(pos);    // tell servo to go to position in variable 'pos'
   
    delay(15);                       // waits 15ms for the servo to reach the position
  }
    for(pos = 90; pos<=180; pos+=1)     // goes from 180 degrees to 90 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
    }
    }
   
   
    // start of right laser sweep, moving right 90 degrees.
    // arrow laser spins and points to right.
   
    if (incomingByte == 'R') {
     Serial.println(incomingByte);
     Serial.println(pos);
    myservo2.write(0);                          // send servo 2 to the 0 degree position
    for(pos = 0; pos < 90; pos += 1)  // goes from 90 degrees to 0 degrees
  { Serial.println(pos);                                 // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
    for(pos = 90; pos>=0; pos-=1)     // goes from 0 degrees to 90 degrees
  { Serial.println(pos);                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
    }
    }
   
    // if a S is sent make sure the servos go to 90 degrees
    if (incomingByte == 'S') {
    Serial.println(incomingByte);
    Serial.println(pos);
    myservo2.write(90);
    myservo.write(90); 
     
     
     
     
    }
  }
}

Please help
15  Using Arduino / Installation & Troubleshooting / Re: I Cant see My Arduino Under Device Manager-Port on: May 12, 2011, 06:25:51 pm
I believe it is a defect in the product so I will buy a new one
Pages: [1] 2