|
A very simple example ([SEE ALL] (https://github.com/RubaXa/Mobius/wiki/))
See http://youtu.be/Y4l9nhQlWT0
#include <Mobius.h>
using namespace Mobius;
LED *led = new LED(10);
LED::Array *indicator = LED::Array::range(2, 9);
Power *power = new Power(500); // duration, ms
Button *btn = new Button(11);
void setup() {
led->setEffect(new Effects::Blink(500));
power->attach(indicator);
btn->attach(power);
power->bind(Power::PROGRESS, &handleEvent);
}
void handleEvent(int id) {
switch (id) {
case Power::VALUE:
if (power->value == 1) {
led->on();
} else if (led->value) {
led->off();
}
break;
}
}
void loop() {
Mobius::strip();
}
#include <Mobius.h>
using namespace Mobius;
Button *btn = new Button(2);
Motor *motor = new Motor(3, 4);
Power *acceleration = new Power(1000);
void setup() {
motor->setDirection(Motor::CW);
acceleration->attach(motor);
btn->attach(acceleration);
}
void loop() {
Mobius::strip();
}
on()
— turn on (1)off()
— turn off (0)setValue(float value)
— set brightness0..1
getValue()
— get brightness0..1
setEffect(Effects::Effect *effect)
byte pin = 13;
LED *led = new Led(pin);
// Add fade effect
led->setEffect(new Effects::Fade(500, 300)); // 500ms — fadeIn, 300ms - fadeOut
// Or blinking effect
led->setEffect(new Effects::Blink(150)); // 150ms — interval between blinks
// Turn on
led->on();
byte startPin = 2;
byte endPin = 12;
LED::Array *bar = LED::Array::range(startPin, endPin);
// Turn on
bar->on();
// Enable only half
bar->setValue(0.5);
pressed:bool
— statetrue
orfalse
attach(Pin *pin)
bind(int eventId, void *callback(int))
— add event listener:Button::DOWN
orButton::UP
byte pin = 10;
Button *btn = new Button(pin);
// Turn on LED by pressing the button
btn->attach(new LED(13));
// Add event listener
btn->bind(Button::DOWN, &handleEvent);
Power *power = new Power(3000); // 3000ms — 0 to 1
Button *btn = new Button(13);
power->attach(LED::Array::range(1, 10));
btn->attach(power);
Support L298N.
Motor *motor = new Motor(2, 3);
motor->setSpeed(1); // max
motor->setSpeed(0); // stop
motor->setDirection(Motor::CW); // OR `Motor::CCW`
Support HC-SR04.
Sensor::Ultrasonic *sonar = new Sensor::Ultrasonic(2, 3);
// Subscribe to the change in distance
sonar->bind(Sensor::Ultrasonic::DISTANCE, &handleEvent);
// Current distance
sonar->value; // cm
- Download the Arduino Software
- Run IDE
- Clone this repository:
git@github.com:RubaXa/Mobius.git
cd Mobius
make all
(Create aMobius.zip
)- IDE: [Sketch] > [Include Library] -> [Add .ZIP Library]
- Enjoy!
#include <Mobius.h>
using namespace Mobius;
// Variables
void setup() {
// Logic
}
void loop() {
Mobius::strip();
}