top of page

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

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

}

Ecco un tutorial fatto da me

bottom of page