Last active
August 19, 2019 04:44
-
-
Save RQF7/87b89a3cf21bf2794a77112ea2bb6542 to your computer and use it in GitHub Desktop.
Majority gate with Cubelets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Program for the wire: a flashlight cube. | |
#include "cubelet.h" | |
void setup() { | |
block_value = 0; | |
} | |
void loop() { | |
if (weighted_average() >= 128) { | |
set_flashlight(0); | |
} else { | |
set_flashlight(255); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Program for a brightness cube. | |
#include "cubelet.h" | |
void setup() { | |
block_value = 0; | |
} | |
void loop() { | |
if (get_brightness() > 250) | |
block_value = 255; | |
else | |
block_value = 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Program for a distance-sensor cube. | |
#include "cubelet.h" | |
void setup() { | |
block_value = 0; | |
} | |
void loop() { | |
if (get_distance() != 0) | |
block_value = 255; | |
else | |
block_value = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment