![](https://static.wixstatic.com/media/afdc09_6ecc222f58bf432aa16dfb2bbaf433a2f000.jpg/v1/fill/w_1280,h_720,al_c,q_85,enc_avif,quality_auto/afdc09_6ecc222f58bf432aa16dfb2bbaf433a2f000.jpg)
SENSORE DI LUCE
Per utilizzare il sensore di luce presente sul robottino dovrete utilizzare per la scrittura a blocchi il codice qui sotto riportato:
![5-mbot.png](https://static.wixstatic.com/media/afdc09_e02aa70ee88f479cb0c09cde158da73c~mv2.png/v1/fill/w_367,h_174,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/5-mbot.png)
Invece per utilizzare il sensore di luce presente sul robottino dovrete utilizzare per la scrittura in arduino il codice qui sotto riportato:
// generated by mBlock5 for mBot
// codes make you happy
#include <MeMCore.h>
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
MeLightSensor lightsensor_6(6);
MeBuzzer buzzer;
MeRGBLed rgbled_7(7, 2);
void _delay(float seconds) {
long endTime = millis() + seconds * 1000;
while(millis() < endTime) _loop();
}
void setup() {
rgbled_7.fillPixelsBak(0, 2, 1);
while(1) {
if(lightsensor_6.read() > 200){
buzzer.tone(700, 1 * 1000);
rgbled_7.setColor(0,0,255,255);
rgbled_7.show();
_delay(1);
rgbled_7.setColor(0,0,0,0);
rgbled_7.show();
_delay(1);
}
_loop();
}
}
void _loop() {
}
void loop() {
_loop();
}