Extension for LittleBits-Arduino - Plain code sketch at beginning?


#1

Hello,

i’m currently working on an mblock-extension for the littleBits Arduino. So far everything is working.
But how can i change the standard/start arduino-code-sketch, that is loaded every time i start the mblock software?
I just want a plain oder simple code sketch (with the setup and loop function) at the beginning.
Is this possible or do i need to code something?

Thanks in advance and greetings from germany


Start block without "runArduino"
#2

You need to select Board -> Arduino to avoid generating boilerplate code.


#3

Hi bigeyex,

thanks for your advice. But in my Version the Arduino-Option ist not choosable.
I’m using Version 3.4.11 for Mac os X.13.3.
Is there maybe anything else i have to change in the settings?
Greetings

mblock_no_arduino_board


#4

Try a relaod of mBlock.


#5

No, didn’t work :frowning:

I think, i’ll reinstall it.


#6

Ah, sorry for the confusion. Choose Arduino Leonardo, which I believe is what the little:bits Arduino block is using, is good.


#7

Hi, okay, it worked.
But i still get no plain start Scetch.
The Sketch that is loaded after mblock starts looks like this:
#include <Arduino.h> #include <Wire.h> #include <SoftwareSerial.h> double angle_rad = PI/180.0; double angle_deg = 180.0/PI; void setup(){ pinMode("a0",INPUT); } void loop(){ if(digitalRead("a0")){ }else{ } _loop(); } void _delay(float seconds){ long endTime = millis() + seconds * 1000; while(millis() < endTime)_loop(); } void _loop(){ }

I was looking for something like:
setup(...my code...) loop( ...my code...)

I now worked around it. But for future work with school-classes it’s a bit confusing, if they see code, they didn’t write.

**I have another question for you: @bigeyex **
The littlebits arduino-bit has three inputs and three outputs. Two of them are labeld A0 and A1 the rest is labeled 0 19.
How can i add the A0 and A1 pin-labels to my JSON file and as option in my custom-made blocks?
Look here for example: https://littlebits.com/tips-tricks/tips-tricks-arduino-module

I can work around it with manually editing the arduino code. But i want my pupils to just program with the blocks in the mblock app.

Thanks!


#8
  1. mBlock 3 has never been good at generating clean code. Wait for 5.
  2. See page 7 of this document (Making Menus)