Skip to content

Instantly share code, notes, and snippets.

@BjoernSchilberg
Last active November 4, 2021 21:08
Show Gist options
  • Save BjoernSchilberg/8f9150858a9b5e7436cfa055a5f6a459 to your computer and use it in GitHub Desktop.
Save BjoernSchilberg/8f9150858a9b5e7436cfa055a5f6a459 to your computer and use it in GitHub Desktop.
Smartibot

Smartibot

“Witchcraft to the ignorant, .... Simple science to the learned”

  • Leigh Brackett

https://www.kickstarter.com/projects/460355237/smartibot-the-worlds-first-ai-enabled-cardboard-ro

Hardware Features

Software Features

Links

Kit contents

  • 1 x Smartibot Circuit Board
  • 2 x DC Motors + Gearboxes
  • 1 x 4AA Battery Box
  • 1 x Cardboard A.I. Bot Parts
  • 1 x Cardboard Unicorn Parts
  • 1 x Cardboard Teabot Parts
  • 2 x Glass Marbles
  • 2 x Screwdrivers Stainless Steel Fixings
  • Rubber Bands

espruino

Activate smartibot module

To activate the smartibot module enter var smarti = require ("Smartibot"); in the code editor window (on the right hand side of the ide) and deploy the code snippet with the deploy button.

After that you can use the module in the terminal and the code editor.

Some system infos

>process.env
={
VERSION: "2v00.90",
  GIT_COMMIT: "ec63efe9",
  BOARD: "SMARTIBOT",
  FLASH: 524288, RAM: 65536,
  SERIAL: "XXXXXXXXXXXXXXXXX",
  CONSOLE: "Bluetooth",
  MODULES: "Flash,Storage,hea" ... "eopixel,smartibot",
  EXPTR: 536882360 }
>process.env.MODULES.split(',')
=[
  "Flash",
  "Storage",
  "heatshrink",
  "net",
  "dgram",
  "http",
  "NetworkJS",
  "crypto",
  "neopixel",
  "smartibot"
 ]
>require("smartibot")
={
  setMotor: function (i,t) { ... },
  aiReset: function () { ... },
  aiDetect: function (i,t,a) { ... },
  load: function () { ... }
 }

Pins (TODO)

pin mode
D0 input
D1 input
D2 input
D3 input
D4 input
D5 input
D6 input
D7 input
D8 input
D9 input
D10 input
D11 input
D12 input
D13 input_pullup
D14 input
D15 input
D16 input
D17 input
D18 input
D19 input
D20 LED1
D21 input
D22 af_output
D23 input
D24 input
D25 input
D26 input
D27 input
D28 input
D29 input_pullup
D30 input
D31 input
function check1() {
var a = BTN1.read();
if (a) console.log("BTN1 pressed!");
}
function check2() {
var b = BTN2.read();
if (b) console.log("BTN2 pressed!");
}
setWatch(check1, BTN1, { repeat: true, edge: "rising", debounce: 20 });
setWatch(check2, BTN2, { repeat: true, edge: "rising", debounce: 20 });
//Preview version
var clkpin = D7;
var datapin = D8;
var sendByte = function(B) {
for (var i = 7; i >= 0; i--) {
clkpin.reset();
digitalWrite(datapin, (B >> i) & 1);
clkpin.set();
}
};
var setLED = function(R, G, B, R2, G2, B2) {
sendByte(0x00);
sendByte(0x00);
sendByte(0x00);
sendByte(0x00);
sendByte(0xff);
sendByte(B);
sendByte(R);
sendByte(G);
sendByte(0xff);
sendByte(B2);
sendByte(R2);
sendByte(G2);
sendByte(0xff);
sendByte(0xff);
sendByte(0xff);
sendByte(0xff);
};
var setMotor = function(M, S) {
var P1, P2;
switch (M) {
case 1:
P1 = D4;
P2 = D6;
break;
case 2:
P1 = D10;
P2 = D11;
break;
case 3:
P1 = D2;
P2 = D3;
break;
case 4:
P1 = D9;
P2 = D12;
break;
}
if (S === 0) {
digitalWrite(P1, 0);
digitalWrite(P2, 0);
}
if (S > 0) {
digitalWrite(P1, 0);
analogWrite(P2, S);
} else {
digitalWrite(P2, 0);
analogWrite(P1, -S);
}
};
var smarti = require("Smartibot");
var wiggling = false; //This variable defines whether
//Smartibot should be wiggling
var wiggleLeft = function() {
smarti.setLEDs([255, 255, 0, 0, 255, 0]);
smarti.setMotor(1, 0.5);
smarti.setMotor(2, 0.5);
setTimeout(function() {
if (wiggling === true) {
wiggleRight();
}
}, 300);
}; //This function makes Smartibot wiggle left for 0.3s
//and then start wiggling right if they should still
//be wiggling
var wiggleRight = function() {
smarti.setLEDs([0, 255, 0, 255, 255, 0]);
smarti.setMotor(1, -0.5);
smarti.setMotor(2, -0.5);
setTimeout(function() {
if (wiggling === true) {
wiggleLeft();
}
}, 300);
}; //This function makes Smartibot wiggle right for 0.3s
//and then start wiggling left if they should still be
//wiggling
var wiggle = function(x) {
if (x > 0) {
wiggling = true;
wiggleLeft();
} else {
wiggling = false;
smarti.setMotor(1, 0);
smarti.setMotor(2, 0);
}
}; //This is the function that we actually call by sending
//Smartibot text (from the app or the command prompt in
//the IDE). To call it we send wiggle() with a number
//inside the brackets. 0 will make Smartibot stop
//wiggling, any greater number will make Smartibot wiggle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment