Graphical programming teaching examples

 人生第一篇博客,水平不好,请大家勿吐槽!
 今天为大家推荐几款国内主流的图形化编程软件。这些软件部分适用于8岁以上,部分适用于12岁以上
  一、图形化软件介绍
  (1)软件一:Scratch
    Scratch是麻省理工学院媒体实验室开发的一款图形化开发工具,代码开源,早期主要用于电脑动画编辑,面向小朋友群体,通过鼠标拖拽的形式放置各种角色及脚本指令,脚本指令通过搭积木的形态提供给小朋友使用,界面直观好用。Scratch的动画和脚本编辑实时响应,用户可随时点击相应指令与动画进行交互,使用门槛很低。

Graphical programming software recommendation 2: Mind+
(2) Software 2: Mind+
Mind+ is a domestic youth programming software with independent intellectual property rights. It is maintained by DFRobot and supported by the Chinese community. In addition to supporting arduino, it also supports other open source hardware such as micro:bit. You only need to drag graphical blocks to complete programming, and you can also use high-level programming languages ​​such as python/c/c++. Mind+ is a special graphical development tool. This software is developed with C++ and Qt. The interface is exquisite. Compared with other splicing instructional programming software, it does have some new ideas. This software abstracts the command flow and data flow in software development and simulates the red and blue broken lines in the graphical interface. The flow of wires reflects the process of program flow and data transmission, making it easy for beginners to understand. Mind+ also has a web-side online programming function, which is convenient to use when you open it, and their community tutorials are also very rich. At present, the domestic primary and middle school students use graphical programming learning and competitions.
(3) Software 3: Mixly
Mixly is also a graphical programming tool for arduino, developed based on blockly. This software has improved some data types and other functions for arduino, which is better than native blockly. Compared with other graphical software, mixly is more lightweight. The upper graphical interface is modified based on open source blockly; the lower-level compilation and download are directly built on the arduino IDE environment; the instructions of the graphical interface are mapped to the arduino native library, so the software It is equivalent to a glue. As long as the functions natively supported by arduino, mixly can be integrated quickly to facilitate iterative software upgrades. The software is released as open source, and third-party vendors can add their own library files or customize them. The disadvantage is that it is too tightly bound to the arduino, it is difficult to have personalized functions, and is always limited by the ceiling of the arduino itself.

 二、Mind+实战案例
 ①光控灯的图形化编程代码和Python编程

Insert picture description here

The language code is as follows:
#include <MPython.h>
// The main program starts
void setup() { mPython.begin(); display.setCursorLine(1); display.printLine("Sound intensity"); } void loop() { display.setCursorLine(2); display.printLine((sound.read())); delay(200); if (((sound.read())>100)) { rgb.write(0, 0x0000FF); delay (1000); } else { rgb.write(0, 0x000000); } } ② Graphical programming code and Python programming for voice control lights #include <MPython.h> // The main program starts void setup() { mPython.begin( ); display.setCursorLine(1); display.printLine("Sound intensity"); }

















Insert picture description here







void loop() {
display.setCursorLine(2);
display.printLine((sound.read()));
delay(200);
if (((sound.read())>100)) {
rgb.write(0, 0x0000FF);
delay(1000);
}
else {
rgb.write(0, 0x000000);
}
}

③Graphic programming code and Python programming for voice recognition control lights

Insert picture description here
#include <MPython.h>
#include <MPython_ASR.h>
#include <DFRobot_Iot.h>
// Function declaration
void DF_YuYinShiBie();
void DF_wifi();
// Create object
MPython_ASR mpythonAsr;
String str_mpythonAsr_result;
DFRobot_Iot myIot;
// The main program starts
void setup() { mPython.begin(); DF_wifi(); DF_YuYinShiBie(); } void loop() {




}

// 自定义函数
void DF_YuYinShiBie() {
display.fillScreen(0);
while (1) {
if ((buttonA.isPressed())) {
while (!(!buttonA.isPressed())) {yield();}
str_mpythonAsr_result=mpythonAsr.getAsrResult(4);
display.setCursorLine(1);
display.printLine((str_mpythonAsr_result));
if (((String(str_mpythonAsr_result).indexOf(String(“开灯”)) != -1))) {
rgb.write(0, 0x0000FF);
delay(5000);
rgb.write(0, 0x000000);
display.fillInLine(1, 0);
}
}
yield();
}
}
void DF_wifi() {
myIot.wifiConnect(“602iot”, “18wulian”);
display.setCursorLine(1);
display.printLine(“正在连接网络”);
while (!myIot.wifiStatus()) {yield();}
display.fillInLine(1, 0);
display.setCursorLine(1);
display.printLine(“网络连接成功”);
display.setCursorLine(2);
display.printLine(“ip地址:”);
display.setCursorLine(3);
display.printLine(myIot.getWiFiLocalIP());
delay(3000);
}

④Realize graphical programming code and Python programming for mqtt message communication on Easy IoT

Insert picture description here
! Error prompt: The password format is wrong, the Wi-Fi password must be 8-20 letters or numbers
/*!

  • MindPlus
  • mpython

*/
#include <MPython.h>
#include <DFRobot_Iot.h>
// Function declaration
void onButtonAPressed();
void obloqMqttEventT1(String& message);
// Static constant
const String topics[5] = {"T_GCbjdGg","OklCbjdGg ”,"","",""};
const MsgHandleCb msgHandles[5] = {NULL,obloqMqttEventT1,NULL,NULL,NULL};
// Create object
DFRobot_Iot myIot;
// The main program starts
void setup() { mPython. begin(); myIot.setMqttCallback(msgHandles); buttonA.setPressedCallback(onButtonAPressed); myIot.wifiConnect("xiaoxian", "123456"); display.setCursorLine(1); display.printLine("Connecting to the network"); while (!myIot.wifiStatus()) {yield();} display.setCursorLine(2);








display.printLine("Connected to the network successfully");
display.fillScreen(0);
delay(2000);
myIot.init("iot.dfrobot.com.cn","q0uh-COMR","","qAX2-jOGRz ”,
Topics ,1883); myIot.connect();
while (!myIot.connected()) {yield();}
display.setCursorLine(1);
display.printLine("mqtt successfully connected");
delay(3000) ;
display.fillInLine(1, 0);
}
void loop() {

}

// Event callback function
void onButtonAPressed() { while (!(!buttonA.isPressed())) {yield();} myIot.publish(topic_0, "吴春贤"); display.fillScreen(0); display.setCursorLine( 1); display.printLine("Send message successfully"); delay(3000); display.fillInLine(1, 0); } void obloqMqttEventT1(String& message) { display.setCursorLine(1); display.printLine("You have New message!”); rgb.write(-1, 0x0000FF); display.setCursorLine(2); display.printLine(message); delay(3000); rgb.write(-1, 0x000000); display.fillScreen( 0); }

















3. Summary
This actual combat case mainly introduces four kinds. There are many software platforms, so I won't introduce them one by one. Friends who are interested in graphics can find more information. If you have any questions, you can ask. Leave me a message, thank you all! The writing is not very good, please Haihan!

Guess you like

Origin blog.csdn.net/weixin_43271542/article/details/108741878