Pages: [1]   Go Down
Author Topic: Xbee and PWN  (Read 345 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm running Processing 1.0.1 and Arduino 16. I just got a set of brand new Xbee series 1 transmitters, an Xbee shield and the Sparkfun Xbee explorer. Using the Processing serial library I was able to have a successful blink on click test via the Xbee radio. However, I was trying to modify this first test to send an analog signal to a PWN pin and I cannot seem to get it going. It accepts the first value sent and then wont change. By the way, it works fine over wired USB. Do Xbees not deal well with PWN? Here is my Arduino code:

Code:
// RECIEVER

byte incomingByte;
int val;
void setup() {

  // start serial port at 19200 bps
  Serial.begin(19200);
  Serial.println("Ready!");

  // led pins

  pinMode (9, OUTPUT);

  delay(1000);

}

void loop() {
  if (Serial.available()) {   // are there any bytes available on the serial port ???
    incomingByte = Serial.read();
    Serial.flush();
    Serial.print(int(incomingByte));
    
    analogWrite(9, incomingByte);
  }else{
    Serial.flush();
    byte incomingByte == 0;
  }
}





and here is my Processing code:

Code:
import processing.serial.*;
import controlP5.*;


ControlP5 controlP5;
Serial myPort;  // Create object from Serial class
int val;  

int sliderValue = 100;

void setup() {
  size(150,150);
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 19200);


  controlP5 = new ControlP5(this);
  Slider s = controlP5.addSlider("slider",0,255,128,10,10,25,100);
}

void draw() {
  val  = round(controlP5.controller("slider").value());

  println(val);
  myPort.write(val);


  background(75);
  fill(sliderValue);
}



Any suggestions. Thanks for helping out a noob. I really super appreciate it.  smiley
« Last Edit: July 31, 2009, 08:22:47 pm by lkacenja » Logged

Pages: [1]   Go Up
Jump to: