Controlling random light generator - arduino to max

    Apr 29 2014 | 1:05 pm
    Hi, I am doing a project using piezo sensors and LEDs going from Arduino to MAX. I have managed to get the piezo sensors working well in MAX, but I have no idea how to deal with the LEDs. I have a random light generator code for arduino, that I need to control with in MAX - is there a way to do that? Here is the code I have for Arduino to MAX:
    int x=0; // a place to hold pin values int ledpin=13;
    oid setup(){
    Serial.begin(115200); // 115200 is the default Arduino Bluetooth speed digitalWrite(13,HIGH); // startup blink delay(600); digitalWrite(13,LOW); pinMode(13,INPUT);
    void loop(){
    if (Serial.available() >0){ // Check serial buffer for characters if('r'){ // If an 'r' is received then read the pins for(int pin=0; pin x=analogRead(pin); sendValue(x);
    for(int pin=2; pin x=digitalRead(pin); sendValue(x); }
    Serial.println(); //Send a carriage return to mark end of pin data. delay(5); //add a delay to prevent crashing/overloading of the serial port
    } } } void sendValue(int x){ //function to send the pin value followed by a "space". Serial.print(x); Serial.write(32); } Here is the code I have for the random light generator: int ranNum;
    void setup() { //Seed random number generator from analog port randomSeed(analogRead(0)); //Setup 3 output ports for LED's pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); }
    void loop() { //Generate random number between 8 and 10 ranNum=random(8,11); //generate 1 second delay delay(1000); //Turn on the LED digitalWrite(ranNum, HIGH); delay(1000); //Turn off the LED digitalWrite(ranNum, LOW); }
    Help would be greatly appreciated.

    • Apr 29 2014 | 4:55 pm
      I can probably help if I have a better understanding of what you’re trying to do. What aspect of the ‘random light generator’ do you want to control from within Max?
    • Apr 30 2014 | 12:43 pm
      I want to be able to turn it on and off using MAX. It's part of a Target Practice game I'm doing for a uni project. Best case scenario, I would be able to turn it on and it would stop after 60 seconds. I just don't know how to mesh both of the arduino codes together and then incorporate the random light flasher in MAX.
      Thank you. I really appreciate your help.