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
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 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 <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
// ----------------------------------------------------------------------------- // 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);