Virtual wire and sound

hello .... i am trying to have a machine (equipe with an arduino (virtual wire library ... TX ) ) sending information over another arduino equiped with virtual wire library(RX) and pduino firmata ( the cicuit is  (resistor 10k from pwm ... to the ground) 330 ohm from pwm to the analogPin() so that i can read analog input into the pd patch ... right?????)

i think the key is how to convert the rx signal into (map, 0, 255,) ... or something like that but the question is how ???...

here is my arduino loop code atemp  a mix of virtual wire and firmata... but it does not work ... anybody have an idea where the problem is

 


void loop()
{uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
    int i;

       
   
    for (i = 0; i < buflen; i++)
    {
        analogWrite(9, (buf[i], DEC));
      
    }

      
       
  byte pin, analogPin;

  /* DIGITALREAD - as fast as possible, check for changes and output them to the
   * FTDI buffer using Serial.print()  */
  checkDigitalInputs(); 

  /* SERIALREAD - processing incoming messagse as soon as possible, while still
   * checking digital inputs.  */
  while(Firmata.available())
    Firmata.processInput();

  /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over
   * 60 bytes. use a timer to sending an event character every 4 ms to
   * trigger the buffer to dump. */

  currentMillis = millis();
  if (currentMillis - previousMillis > samplingInterval) {
    previousMillis += samplingInterval;
    /* ANALOGREAD - do all analogReads() at the configured sampling interval */
    for(pin=0; pin<TOTAL_PINS; pin++) {
      if (IS_PIN_ANALOG(pin) && pinConfig[pin] == ANALOG) {
        analogPin = PIN_TO_ANALOG(pin);
        if (analogInputsToReport & (1 << analogPin)) {
          Firmata.sendAnalog(analogPin, analogRead(analogPin));
        }
      }
    }
  }
}

**i tried to get the code working

i tried to get the code working this way now … it’s halfay there now … but i don’t get the right reading in puredata anybody can help me

 

here is my code so far

 

/

This firmware supports as many analog ports as possible, all analog inputs,
 
four PWM outputs, and two with servo support.
 
 
This example code is in the public domain.
 /

#include <Firmata.h>
// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley ([email protected])
// Copyright © 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
/
==============================================================================
 * GLOBAL VARIABLES
 ============================================================================/



/* analog inputs /
int bank = 0; // bitwise array to store pin reporting
 // counter for reading analog pins
/
timer variables /
unsigned long currentMillis;     // store the current value from millis()
unsigned long previousMillis;    // for comparison with currentMillis


/
==============================================================================
 * FUNCTIONS                                                               
 ============================================================================/



// -----------------------------------------------------------------------------
// sets bits in a bit array (int) to toggle the reporting of the analogIns
void reportAnalogCallback(byte pin, int value)
{
    if(value == 0) {

    }
    else { // everything but 0 enables reporting of that pin

    }
    // TODO: save status to EEPROM here, if changed
}

/==============================================================================
 
SETUP()
 ============================================================================/
void setup()
{
   vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);     // Bits per sec
vw_set_rx_pin(11);
    vw_rx_start();
    Firmata.setFirmwareVersion(0, 2);

    Firmata.attach(REPORT_ANALOG, reportAnalogCallback);

  
    Firmata.begin(57600);
}

/==============================================================================
 
LOOP()
 ============================================================================/
void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
 
 
 
     
        {
           if (vw_get_message(buf, &buflen)) // Non-blocking
         
              {
                 bank = buflen;

              digitalWrite(13, true);
             
                 while(Firmata.available()){
                
                Firmata.sendAnalog(4, (buf[bank], DEC));
                 }
  
                delay(1000);
                   digitalWrite(13, false);
                   delay(100);
                 
              }
    }
}

i think it has to do with

i think it has to do with this line

  …          Firmata.sendAnalog(4, (buf[bank], DEC));

 

Have you asked on the

Have you asked on the arduino forum? They’ll probably spot the problem and help you fairly quickly :slight_smile:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl

i am currently trying on

i am currently trying on arduino’s playground …  LMR is also very usefull … it helped me a lot … thanks