Make rbg stripe work with sound sensor?


#1

Pls help me the code for sound sensor work with rgb stripe look like in this video?


#2

Cool video! I’m guessing you could not do this with mBlock as I see no way of addressing each LED individually with the scratch LED block. I’m hoping each module will eventually be controllable from mBlock so my kids can play with them.


#3

I was playing around last night and modified one of the RGB examples to work with the sound sensor. This is using the 15 LED strip:

#include "Makeblock.h"
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>

MeRGBLed led(PORT_3,SLOT1);
MeSoundSensor mySound(PORT6);

void setup()
{
  // set the led quantity.
  led.setNumber(15);
  
  //clear LEDS
  for(int z = 1; z <= 15; z++){
    led.setColorAt(z,0,0,0); 
  }
}
int lastNum = 0;
int getSound = 0;


void loop()
{
  getSound = mySound.strength() / 50;
  
  indicators(getSound,200,10,10);
  delay(60);
}
void indicators(int count,byte r,byte g,byte b){
  byte inSpeed = 10;
  if(lastNum <= count){
      for(int x = lastNum; x <= count; ++x){
          led.setColorAt(x,r,g,b);
          led.show();
          delay(inSpeed);
      }
    }
    else{
      for(int x = lastNum; x > count; --x){
          led.setColorAt(x,0,0,0);
          led.show();
          delay(inSpeed);
      }
    }
    lastNum = count; 
}

#4

As I know currently there is way to control each LEDs on the Strip with “set led” block. can you translate it with mblock?


#5

Hi Trapasis,

Nice to meet you. I have tried to make Scratch code with your arduino code, but it does not work. Could you kindly help me or share your thinking? I`ve linked my post here where I am discussing with another guy for this issue.

Thanks!

where I am talking!


#6

@Hoang_Phat this is mBlock project for ledstrip color loop.
colorloop.sb2 (74.7 KB)


#7

I converted my code to mBlock based on some information from the Makeblock folks. Here is the screen shot of the code:

However it looks like the other thread has some better examples. The key to making it work is to always plug the light strip into slot 2 of the RJ25 adapter. Slot 1 will not work. BTW I am also using the 7-segment display to show the sound value but you don’t need that. Good Luck!


#8

Thanks!. It looks like mblock(Scratch) does not support global variable in “Make a block”.


#9