5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10



ARDUBLOCK Project 8: Light-controlled Sound

Posted by Fiona Su on

Introduction:
Photovaristor is a resistor using the photoelectric effect of a semiconductor. Its resistance changes along with the intensity of the incident light, the greater the intensity, the lower the resistance, the less the intensity, the higher the resistance. It has wide application in various light-controlled circuits, such as lighting control, regulation, light-controlled switch etc.
In this project, we use graphical programming to display analog value of illumination intensity measured by photovaristor. And set this value as frequency of sound production.
Materials Required:

  • 1. KEYESTUDIO UNO Control Board *1
  • 2. V5 Sensor Shield*1
  • 3. Photovaristor Module*1
  • 4. Photovaristor Module
  • 5. Female to Female Dupont Line*6

Connection Diagram:

thumb

thumb

After wiring, we can start programming.
In this project, we apply similar method in "reading analog value". Directly connect the photovaristor to analog port. The analog value varies with the intensity of light and controls the sound frequency produced by passive buzzer.

thumb

Click “download to Arduino” to see the following codes in IDE interface:
Sample Code:

*****************************************************************************
int _ABVAR_1_val = 0 ;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  _ABVAR_1_val = analogRead(0) ;
  Serial.print("light:");
  Serial.print(_ABVAR_1_val);
  Serial.println();
  tone(8, _ABVAR_1_val);
  delay( 500 );
}
*******************************************************************************

Result:
After downloading the program, have a kook at the value of serial monitor.

thumb 

The value indicates the light intensity, and the larger the value, the stronger the light intensity. Meanwhile, the value belongs to the sound frequency produced by passive buzzer.

All Projects

Buy it >> ARDUBLOCK Graphical Programming Starter Kit for Arduino

0 comments

Leave a comment

Please note, comments must be approved before they are published