Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let isOn = false;
- let mode = false;
- if (sensors.color1.light(LightIntensityMode.Ambient)) {
- brick.setStatusLight(StatusLight.Off);
- isOn = false;
- }
- else {
- brick.setStatusLight(StatusLight.Orange);
- isOn = true;
- }
- brick.showString("Automatic", 1);
- // Funciones para manejar las luces
- function autoLights() {
- if (sensors.color1.light(LightIntensityMode.Ambient)) {
- brick.setStatusLight(StatusLight.Off);
- isOn = false;
- }
- else {
- brick.setStatusLight(StatusLight.Orange);
- isOn = true;
- }
- }
- function manualLights() {
- if (brick.buttonEnter.isPressed()) {
- while (brick.buttonEnter.isPressed())
- { }
- brick.setStatusLight((isOn) ? StatusLight.Off : StatusLight.Orange);
- isOn = (isOn) ? false : true;
- }
- }
- forever
- (
- function () {
- while (true) {
- if (brick.buttonDown.isPressed()) {
- while (brick.buttonEnter.isPressed())
- { }
- mode = (mode) ? false : true;
- brick.showString((mode) ? "Manual" : "Automatic", 1);
- }
- if (mode) {
- manualLights();
- }
- else {
- autoLights();
- }
- }
- }
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement