Show Posts
Pages: 1 2 [3] 4 5 6
31  Using Arduino / Microcontrollers / Re: Clock signal on a digital pin on: February 14, 2013, 02:49:46 am
It would also better if anybody can show me how to bootload an Arduino Pro mini 3.3 volt. Any tutorial link for promini 3.3V will do.
32  Using Arduino / Microcontrollers / Re: Clock signal on a digital pin on: February 13, 2013, 01:21:01 pm
Thanks will try it out soon tomorrow
33  Using Arduino / Project Guidance / Re: Servo control on: February 13, 2013, 12:50:56 pm
Thanks PETER for your constant support. Power cut is going on here. Also tired of all the discussions through-out the day. will let you know tomorrow.
Should I also keep the out-put value from the arduino-one as "byte" or "int"? And the servo.Write() & serial.Println() should be in void loop() or event-handler loop?
34  Using Arduino / Project Guidance / Re: Servo control on: February 13, 2013, 11:24:20 am
Yes; Arduino 2 is receiving the correct values. Can you please state how to do that. I'm new new to this.
 Do you mean something like this:

Code:
#include <Wire.h>
#include <Servo.h>

Servo myservo;
volatile int x = 0;

void setup()
{
  Serial.begin(9600);
  myservo.attach(9);
  Wire.begin(4);               
  Wire.onReceive(receiveEvent);
}

void loop()
{
   myservo.write(x);
   Serial.println(x);
   Serial.flush(); 
   delay(5);
}

void receiveEvent(int howMany)
{
   x = Wire.read();
   
  }
35  Using Arduino / Microcontrollers / Clock signal on a digital pin on: February 13, 2013, 11:05:59 am
Hello everyone.
I recently came up with a post where we can connect a hacked nintendo wii's pixart camera to Arduino via I2C. In the post they suggested that the camera's CLK, need to be 18, 20-25 MHz for 5 volt uControllers.
http://www.stephenhobley.com/blog/2009/03/01/pixartwiimote-sensor-library-for-arduino/comment-page-1/#comments
A guy named Adam McDonald commented in the same post that he's been able to use the clock signal of 8MHz from his Pro mini of 3.3v I/O lines  to the pixart camera.
Now I need a method be explained to me in an easy manner of "getting an 8Mhz signal by setting the fuse bytes on the Arduino to output the clock signal on a digital pin" (I don't understand how to get that 8MHz signal).
For that you obviously don't need to know that what I'm going to do with that signal. Just assume I need it?
Can anybody help me here with some real solutions.
Thanks in advance
36  Using Arduino / Project Guidance / Re: Servo control on: February 13, 2013, 10:03:20 am
My servo's working fine(ran the "sweep" example with success). Also I tried to read the data coming to the 2nd arduino in the serial monitor (for my case COM-4) as I applied on the slider in applet running by processing, sending serial data to the first arduino(COM-14). I was communicating successfully.
 Here are the codes :
------------Processing applet code--------------
Code:
import processing.serial.*;
import controlP5.*;

Serial port;
ControlP5 cp5;

int tilt = 0;

void setup()
{
size(200, 200);

port = new Serial(this, "COM4", 9600);
//port.bufferUntil('\n');

cp5 = new ControlP5(this);

cp5.addSlider("tilt")
     .setPosition(88,7)
     .setSize(20,180)
     .setRange(0,180)
     .setValue(90)
     ;
}

void draw()
  {
    background(0);
    println(tilt);
    port.write(tilt);
  }

Arduino code which will receive serial data from the Processing & communicate with other arduino through I2C.

------------Arduino One Code-------------------
Code:
#include <Wire.h>

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

int x = 0;

void loop()
{
  while(Serial.available())
  {
    x = Serial.read();
   
    Wire.beginTransmission(4);
    Wire.write(x);
    Wire.endTransmission();
   
    Serial.flush();
   
    delay(20);
  }
}

the code for Arduino which will receive data fro the 1st arduino & print the results in the serial monitor.

----------------Arduino Two Code--------------------

Code:
#include <Wire.h>
#include <Servo.h>

Servo myservo;

void setup()
{
  Serial.begin(9600);
  myservo.attach(9);
  Wire.begin(4);               
  Wire.onReceive(receiveEvent);
}

void loop()
{
   delay(5);
}

void receiveEvent(int howMany)
{
   int x = Wire.read();
   myservo.write(x);
   Serial.println(x);
   Serial.flush(); 
  }

I guess the servo is getting same value multiple times & thus is freaking out(As it is coming serially all the time). I need to use something that will let the servo pick up a changed values once (as they change) only to make it move & not the same value continuously coming over serially to first arduino & to it through I2C finaly.
 Something to flush the excess data.

Can any body test anything on this & help with a modified code please?
37  Using Arduino / Project Guidance / Re: Servo control on: February 13, 2013, 03:05:03 am
I've modified the reciever arduino code a little. But not working still. Is it because there is something missing in the code or since I've not used Pull ups in tn the I2C bus? The servo keeps on rotating.

Code:
#include <Wire.h>
#include <Servo.h>

Servo myservo;
int pos = 0;

void setup()
{
  Wire.begin(4);               
  Wire.onReceive(receiveEvent);
  myservo.attach(9);
}

void loop()
{
  delay(100);
}

void receiveEvent(int howMany)
{
  pos = Wire.read();   
  myservo.write(pos);
}
38  Using Arduino / Project Guidance / Re: Servo control on: February 12, 2013, 02:26:12 pm
\until & unless the data over I2C is 0, it'll keep on reading & set that value to a variable x. This variable is then used to define the position of a servo
39  Using Arduino / Project Guidance / Re: Servo control on: February 12, 2013, 02:09:10 pm
Well I tried with both the low pass filter way & the  i2c way. low pass filter had some glitches. Sometimes it worked just fine. The system is not dependable for crucious moments. moving on to I2C.

The code for the arduino which will receive serail data from the Processing app is :

Code:
#include <Wire.h>

int data = 0;

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

void loop()
{
  while(Serial.available() == 0)
  {
    int data = Serial.read() - '0';
    Wire.beginTransmission(4);
    Wire.write(data);
    Wire.endTransmission();
    Serial.flush();
  }
  delay(50);
}

& the code for the arduino that is connected to the previous arduino with I2C & a servo is

Code:
#include <Wire.h>
#include <Servo.h>

Servo myservo;
int x = 0;

void setup()
{
  Wire.begin(4);                // join i2c bus with address #4
  Wire.onReceive(receiveEvent); // register event
  //Serial.begin(9600);
  myservo.attach(9);
}

void loop()
{
  //delay(100);
  myservo.write(x);
  //Servoflush();
}

void receiveEvent(int howMany)
{
  while( Wire.available() == 0) // loop through all but the last
  {
      x = Wire.read();    // receive byte as an intege
  }
}

The problem is the servo keeps on moving . Never stops & is not affected by the serial data coming over the first arduino.
I guess there is some random data like the -49 for the subtraction (- '0') that we are employing in the first arduino program is causing the problem. My best guess. Any more problems sorted out & fixable is needed. help again. smiley-sad 
40  Using Arduino / Programming Questions / Re: Serial communication querry on: February 12, 2013, 10:03:51 am
like 1-wire & i2C?
41  Using Arduino / Project Guidance / Re: Servo control on: February 12, 2013, 07:33:26 am
Searching for a while, i found these
http://arduino.cc/forum/index.php?topic=116015.0
where a similar problem was raised & a person suggested something like I thought with analog read & write ()s .
42  Using Arduino / Project Guidance / Re: Servo control on: February 12, 2013, 07:17:53 am
Code:
//-------------------ARDUINO CODE----------------------//
//Arduino 1 code:

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


void loop()
{
  while(Serial.available() == 0);
  {
    int pos = Serial.read() - '0';
    analogWrite(A0, pos);
    Serial.flush();
  }
}

Code:
//Arduino 2 code:

#include <Servo.h>

Servo myservo;

void setup()
{
  myservo.attach(9);
  Serial.begin(9600);
}


void loop()
{
  int data = analogRead(A0);
  Serial.println(data);
  myservo.write(data);
  //Servo.flush();
}

Code:
//------------------------PROCESSING APPLET-------------------//

//code:

import processing.serial.*;
import controlP5.*;

Serial port;
ControlP5 cp5;

int tilt = 0;

void setup()
{
size(200, 200);

port = new Serial(this, "COM14", 9600);
//port.bufferUntil('\n');

cp5 = new ControlP5(this);

cp5.addSlider("tilt")
     .setPosition(88,7)
     .setSize(20,180)
     .setRange(0,180)
     .setValue(90)
     ;
}

void draw()
  {
    background(0);
    println(tilt);
    port.write(tilt);
  }
43  Using Arduino / Project Guidance / Re: Servo control on: February 12, 2013, 06:49:44 am
And more over, it would be just helpful if you could help me with the problem I raised here. This way you would be saved of a lot of burden. I need to know about the filtering as you said up there & modifying it in my code will help me better understand .
Thank you
44  Using Arduino / Project Guidance / Re: Servo control on: February 12, 2013, 06:45:53 am
I think I've given a link back up there about another discussion. It'll give you a better insight about what I'm up-to. please go through 'em
45  Using Arduino / Project Guidance / Re: Servo control on: February 12, 2013, 06:27:25 am
I'm new to this. So what shall exactly be done?
Pages: 1 2 [3] 4 5 6