As you can see from the image below, I have three blocks that do run the code that I have specified in the declare: editor and then activated by running my run-once-only coding sequence of named procedures in the setup: editor of the Upload transcode tab for each block.
BUT - If the two blocks that define the buzzer and LEDs are used together (or with other similar block types from the blocks palette list) then the code that they generate duplicates the definition of any connected Me modules & Me device components that have been already specified in the transcode, and these double-entries of common code that cause the code to crash and not upload correctly. Why, and how can I fix this?
The two blocks shown above do work together - but only because they have no definition conflicts. Could anyone who knows about these things kindly explain what bit of extra coding I need to add (& where) to prevent such duplication when similar block types, as described above, are joined into one programme.
I also put all of my own self-defined Functions in the declare: section of each of these blocks. Should such self-defined Functions be written in the code: section instead? As you can see in the transcoded Arduino C code above, they do appear where you would expect them to.
As I said in my original post, these extension blocks do work OK, but it is the double-entries of common code that cause the code to crash and not upload correctly if similar-type blocks are used together. The two blocks I showed do work together OK as the the transcoded Arduino C code demonstrates - but only because they have no definition conflicts. I think that Functions or variables that are shared by multiple blocks are referred to as common functions or variables. How can I define and modify them in a centralized way by configuring what I think is refered to as common code?
Move the code in the setup section to the code section and see if that helps. mBlock will auto put anything in the code section in the setup() or loop() code.
It might seem strange, but just give it a try.
It may work, it may not.
@Best_Codes Thanks for your idea of moving code from the setup: section to the code: section. I can confirm that this worked OK and the codes ran OK and as before. There was one success and one failure here.
The first problem that I outlined has not been solved - this occurs if two blocks of similar block types from the blocks palette list are used together in a script. The code that they generate duplicates the definition of any connected Me modules & Me device components that have been already specified in the transcode and these double-entries of common code cause the code to crash and not upload correctly.
Ok, I do have a workaround solution for now, but I would still like to solve the problem of these double-entries causing the code to crash. These block experiments are not a project in their own right, but a way to examine and understand the nuances of coding within the Extension Builder.
This chapter describes the device library and extension center of mBlock 5. The updates of devices and extensions are provided in the device library and extension center, and therefore no extra update is needed on the mBlock 5 software.
Different from devices, device extensions or sprite extensions can be created through templates. Currently, a default Arduino template is provided for Arduino extensions and a universal template is provided for other extensions.
Compared to S4A and other block-based programming environment, mBlock allows both interacting with screen sprites and compiling/uploading Arduino code onto the board. Further more, mBlock allows anybody familiar with Arduino to write extensions - for example, I wrote an extension for my Seeed Studio Grove sensors (Disclaimer: I do not work for Seeed Studio) and debugged it in 2 hours. Other users can search, download and install the extension people wrote with a single click.
In my spare time, I wrote one for Seeed Studio products. But there are too many products in the market thus I can't write for everything hardware. It's pretty simple: just fill in what should be inserted to which part of the Arduino Sketch and it works.
For anyone who is interested in using the mBlock (Scratch-based) environment to access a Pixy2, I created an extension to add Pixy2 blocks for this environment. Here is the description and the package:
GitHub grantgunner/mblock-pixy2Contribute to grantgunner/mblock-pixy2 development by creating an account on GitHub.
My kids like easy coding with Scratch or mBlock. I found a nice Arduino shield for them to play with, only it could only be programmed with the Arduino IDE. Luckily mBlock provided a way to extent the mBlock environment.
The Arduino Multi Function Shield is a low cost shield provided by several suppliers.
It contains a lot of basic IO for fun experiments. Typical the stuff you put normally first on a breadboard.The shield contains:
mBlock is a Scratch like IDE for making computer program, but it also supports several hardware platforms like the mBot, but also Arduino. My kids use this very accessible environment for the mBot, but is also support other hardware like the Arduino Uno.
To make the it able to use the Arduino shield in mBlock, a so called extension should be created for it in the mBlock online extension builder.
When a extension is finished it can be published for approval. In the will so up in the Extension store.
If you only have one button test you can use the get button state block directly in the eval block. If you have multiple you first need to store the button state into a variable and use that variable in the eval:
An MBLOCK file is a project created with Makeblock mBlock, a visual block-based and Python coding tool primarily used to teach kids programming basics. It is a Zip-compressed archive that contains various files that make up a program, such as a small game, animation, music lighting show, or robot maneuvers.
You will most likely only encounter an MBLOCK file if you use the mBlock application to create and save programs. mBlock is a STEAM education tool that implements Science, Technology, Engineering, Arts, and Mathematics (STEAM) principles to help kids learn programming basics.
Since MBLOCK files are compressed with Zip compression you can extract the contents of the files with Zip utilities, such as Corel WinZip, 7-Zip, or Apple Archive Utility. Change the .mblock file extension to .zip and unzip the file with the Zip utility.
The FileInfo.com team has independently researched the mBlock Project file format and Mac, Windows, Android, and iOS apps listed on this page. Our goal is 100% accuracy and we only publish information about file types that we have verified.
Extension for Arduino and teaching MAXI Starter Kit. This extension contains functions and procedures to support all modules of the MAXI Starter Kit. The MAXI Starter Kit contains about thirty lessons for Arduino. There are many additional devices such as LCD, servo, temperature, humidity sensor, IR receiver, RFID reader and more in this kit. With this our extension, you can easily create all the lessons from the tutorial for this Arduino-kit in mBlock.
This extension adds a command block to the mBlock environment to generate at least "quite" random number. The standard Random() function for the Arduino module generates pseudo random numbers. This often results in the same numbers being generated over and over again when the Arduino module is turned on.
Extension for Ethernet-Shield (Ethernet Shield allows an Arduino board to connect to the internet). This extension is designed to work with the Arduino Ethernet Shield and any other W5100/W5200/W5500-based devices. The extension allows an Arduino board to connect to the Internet. The extension contains blocks for creating a simple measurement server and a simple web client. The extension is mainly intended for Arduino UNO and Leonardo. The functions for controlling the SD card, which is located on the Shield, are not included in this extension.
As an example, we will show remote switching on and off of LED via the Internet. Connect the Ethernet Shield to the arduino module. Connect the LED with the auxiliary resistor between the GND and digital pin 9. (See Fig. - Ethernet Shield is not drawn).
Enter the URL: in your internet browser. This loads the control HTML page from the Arduino module. The loaded web page contains two radio buttons. The first button lights up the LED on pin 9, the second button turns off the LED. The selection must be confirmed (sent) with the "Update STATUS" button! The code tests whether the GET query contains the parameter LED=on/off. Sets the status of the LED accordingly. If you enter a URL other than ARD.htm, the standard error "404 Not Found!" is returned.
Connect the Arduino with Ethernet Shield to a computer with the IP address set to 192.168.0.1, on which you will start the web server. The files on the web server will be available for Arduino! In the following example, Arduino queries the index.htm file and writes its first 255 characters to the Serial port. Loading index.htm file is repeated at 15 second intervals.
I've seen cookies set by web pages with the "." character in them. I'm trying to maximize the dynamic use of a $_GET['url'] to set my cookies, and then include it in a next page as a conditional where it checks to make sure the cookie was set before it allows users to perform an action. Basically I'm using cookies and IP addresses in an anonymous voting action to make sure anyone who votes only gets one per day. IPs are reset through a cron job once a day, and the cookies are set to expire after 17 hours. I have no issues setting a cookie named with the .php extension, however after many hours of trial and error, I can't get it to accept it in an if(isset). No matter what I try, it will not recognize that the cookie is set. Without the extension everything works fine. I've tried a dozen configurations, but here's basically what I have trying to debug.
c80f0f1006