单片机编程m序列4位程序_教人们编程2019年,也就是寻找理想的程序:序列

单片机编程m序列4位程序

MUROM

Hi, my name is Michael Kapelko. I'm a professional software developer. I'm fond of developing games and teaching folks to program.

嗨,我叫Michael Kapelko。 我是专业的软件开发人员。 我喜欢开发游戏并教人们编程。

Preface

前言

Autumn 2019 was the third time I participated as one of the teachers in the course to teach 10-15-year-old folks to program. The course took place from mid. September to mid. December. Each Saturday, we were studying from 10 AM to 12 PM. More details about the structure of each class and the game itself can be found in the 2018 article.

2019年秋季是我第三次以其中一位老师的身份参加课程,教10-15岁的人进行编程。 该课程从中旬开始。 9月中旬。 十二月。 每个星期六,我们从上午10点到下午12点进行学习。 有关每个类的结构和游戏本身的更多详细信息,请参见2018年文章

I have the following goals for conducting such courses:

我进行此类课程的目标如下:

  • create a convenient tool to allow the creation of simple games, the tool interested folks of 10 years old or older can master;

    创建一个方便的工具以允许创建简单的游戏,使10岁以上的人感兴趣的工具可以掌握;
  • create a program to teach programming, the program interested folks of 10 years old or older can use themselves to create simple games.

    创建一个程序来教编程,该程序使10岁或10岁以上的人感兴趣,他们可以自己制作简单的游戏。

Game

游戏

Game

Memory is a simple game we create during the course. The goal of Memory is to find matching items on a playing field. More details, including game mechanics, can be found in the 2018 article. You can play the created game in a web browser by clicking this link.

记忆是我们在课程中创建的一个简单游戏。 记忆的目标是在运动场上找到匹配的项目。 更多细节,包括游戏机制,可以在2018年文章中找到。 您可以通过单击此链接在Web浏览器中玩创建的游戏。

Tool

工具

IDE

When I was creating the tool, my guiding principle was unpretentiousness that manifests itself in the following:

在创建工具时,我的指导原则是朴实无华 ,体现在以下方面:

  1. work under any operating system

    在任何操作系统下工作

    • development can be conducted under Linux, macOS, or Windows

      开发可以在Linux,macOS或Windows下进行
    • one can play the game on a PC, a tablet, or a smartphone

      可以在PC,平板电脑或智能手机上玩游戏
  2. no need to configure anything: just open the link in a web browser and start working

    无需进行任何配置:只需在网络浏览器中打开链接即可开始工作
  3. no need for the Internet: work locally if you want, there's no back-end

    无需互联网:如果需要,可以在本地工作,没有后端
  4. the game is available to everyone

    每个人都可以使用该游戏

    • if you place a file on GitHub Pages, just share the link

      如果您将文件放在GitHub Pages上,只需共享链接
    • if you send the file over Skype, just open the file locally

      如果您通过Skype发送文件,只需在本地打开文件

The tool is an integrated development environment (IDE) that is technically a single HTML file. This single file contains both IDE and a project under development (Memory game in our case). The tool looks pretty standard:

该工具是一个集成开发环境(IDE),从技术上讲它是一个HTML文件。 这个文件包含IDE和正在开发的项目(在我们的例子中为Memory游戏)。 该工具看起来很标准:

  1. left area depicts the code of a selected module;

    左侧区域描述了所选模块的代码;
  2. middle area contains buttons to restart, save the project and manage modules;

    中间区域包含用于重新启动,保存项目和管理模块的按钮;
  3. top right area contains result;

    右上方区域包含结果;
  4. bottom right area lists modules belonging to both IDE and the project.

    右下区域列出了同时属于IDE和项目的模块。

Since we only have a single HTML file, we should be able to run it in two modes:

由于我们只有一个HTML文件,因此我们应该能够以两种模式运行它:

  1. replay

    重播

    • default mode;

      默认模式
    • just open the file;

      只需打开文件;
  2. editing

    编辑

    • append ?0 symbols in the address bar.

      在地址栏中添加?0符号。

Web browser cache (IndexedDB) is used to keep changes temporarily. To save changes permanently, one has to download the file with the changes by clicking the corresponding button in the middle area.

Web浏览器缓存(IndexedDB)用于暂时保留更改。 要永久保存更改,必须单击中间区域中的相应按钮来下载包含更改的文件。

The first classes

头等舱

I prepared 80 lines of JavaScript code for the first class and printed the code on paper. Each student received the paper and had to type the code into the tool. The typing exercise had the following goals:

我为第一堂课准备了80行JavaScript代码 ,并将代码打印在纸上。 每个学生都收到了论文,并且不得不在工具中输入代码。 打字练习具有以下目标:

  1. find out the typing speed of students;

    找出学生的打字速度;
  2. demonstrate API of the tool.

    演示该工具的API。

The typing speed turned out to be extremely low: ranging from 14 symbols per minute (a student managed to type only half of the code) to 39 symbols per minute. Since I used to type the code with the speed of 213 symbols per minute, I was shocked by the results and started to doubt we would be able to write the game in an hour by the end of the course.

打字速度非常低:从每分钟14个符号(一个学生只能键入一半的代码)到每分钟39个符号。 由于我以前以每分钟213个符号的速度键入代码,因此我对结果感到震惊,并开始怀疑我们能否在课程结束后的一个小时内编写游戏。

We spent the second class to find typos in the code. I met typos that I have never seen in my life. I was shocked again: students had a hard time finding the typos even with the correct code on the paper in front of them. It's hard to imagine what would happen to the students' psyche if we were to pass a brutal UX/UI test with questions like this:

我们花了第二节课在代码中查找错别字。 我遇到了我一生中从未见过的错别字。 我再次感到震惊:即使在他们面前的纸上有正确的代码,学生也很难找到错字。 很难想象如果我们通过残酷的UX / UI测试并遇到以下问题,将会对学生的心理产生什么影响:

Can't unsee

Later I tried to decrease the code down to 10 lines, offered partially completed code so that students could find and fix errors. Nothing helped: students just couldn't comprehend anything as if they saw hieroglyphs instead of familiar letters.

后来我试图将代码减少到10行,提供部分完成的代码,以便学生可以发现并修复错误。 没有任何帮助:学生只是无法理解任何东西,就像他们看到象形文字而不是熟悉的字母一样。

Successful seventh class

成功的七年级

The half of the course was over, and I haven't moved an inch. In another attempt to find a way to explain the code I rewrote the game one more time. Now with a module of an intriguing title последовательность (sequence in Russian). To my surprise, the class had a stunning success: we got everything done before "the bell rang", and the students were burning with enthusiasm. The burning was so strong that we finished the class with a spontaneous brainstorm session where we came up with functionality to make the newly appeared game even better:

课程的一半结束了,我还没动一下。 为了找到一种解释代码的方法,我再次重写了游戏。 现在带有一个有趣的标题последовательность (俄语sequence )的模块。 令我惊讶的是,这堂课取得了惊人的成功:我们在“钟声响起”之前就完成了所有工作,学生们热情洋溢。 燃烧是如此强烈,以至于我们通过自发的头脑风暴会议结束了课堂,在会议上我们提出了使新出现的游戏变得更好的功能:

Brainstorm

The lines in Russian read:

俄语行如下:

  • timer;

    计时器
  • tutorial;

    教程;
  • sounds;

    声音
  • the camera should be farther;

    相机应该更远;
  • randomize;

    随机化
  • hearts (meaning lives);

    心(意为生命);
  • randomize after a failed matching attempt;

    匹配尝试失败后随机分组;
  • exploding spheres;

    爆炸领域
  • levels with different number of spheres;

    不同球数的水平;
  • background.

    背景。

Let's look closer into the class.

让我们仔细看一下这堂课。

Board

Previous classes were using "teachers work with each student individually" approach. After six classes we (two teachers) realized that diving into each student's specific typos/errors takes more time than teaching anything new.

以前的课程使用“老师与每个学生分别工作”的方法。 经过六堂课,我们(两名老师)意识到,深入学习每个学生的特定错别字/错误要比教任何新内容花费更多的时间。

Starting with the seventh class, we decided to hook everyone to the board, i.e., the board became a central place where all of us were working, a place for everyone to stand up, approach the board and write there. PCs became secondary, a place for students to copy the board contents to. This practice clearly indicated school boards exist for many reasons:

从第七堂课开始,我们决定让所有人都加入董事会,即董事会成为我们所有人工作的中心场所,每个人都可以站起来,走近董事会并在那里写作。 PC成为次要的东西,学生可以在其中复制板子内容。 这种做法清楚地表明存在校务委员会的原因很​​多:

  • every student is accustomed to receiving information from the board; students know what to observe;

    每个学生习惯于从董事会接收信息; 学生知道要观察什么;
  • teacher's environment is at the board; it's now possible to explain single new item to everyone without diving into individual errors;

    老师的环境在董事会中; 现在可以向每个人解释一个新项目,而无需深入探讨单个错误;
  • fixing individual errors becomes faster because most of them stem from negligence, i.e., typos made while copying the board contents.

    修复单个错误的速度变得更快,因为大多数错误源于疏忽大意,即在复制电路板内容时出现错别字。

I'd like to highlight the fact that teachers work at the board together with students: a teacher sets direction; however, students stand up and come to the board themselves, write answers to the teacher's questions themselves. The benefits of such an approach are the following:

我想强调一个事实,即老师与学生一起在董事会工作:老师设定方向; 但是,学生要站起来亲自上板,自己为老师的问题写答案。 这种方法的好处如下:

  • students write with their own hands, i.e., they come up with a solution and implement it themselves, a teacher does not write for them;

    学生用自己的双手写作,即他们想出了一个解决方案并自己实施,而老师却没有为他们写作。
  • students stand up and come to the board, i.e., they move, which is good for health and drains unbridled energy that usually hampers discipline;

    学生站起来进入董事会,即他们走了走,这对健康有好处,并消耗了通常妨碍纪律的精力充沛的精力;
  • students have to remember the code to copy it to the board;

    学生必须记住代码以将其复制到黑板上;
  • teachers have an opportunity to evaluate students' observation skills by seeing how easy (or hard) it is for them to remember and write the code on the board.

    老师有机会通过观察他们记住并在板上写下代码的难易程度来评估学生的观察技能。

Sequence

序列

последовательность module of the game looks like this:

游戏的последовательность模块如下所示:

Sequence

The sequence allows to write an algorithm in the form of events and reactions:

该序列允许以事件和React的形式编写算法:

  • events (начало (start), выбор (selection), etc.) are lines without indentation;

    事件( начало ( start ), выбор ( selection )等)是没有缩进的行;

  • reactions (настроить ThreeJS (configure ThreeJS), показать заставку (show splash screen), etc.) are lines with indentation to signify their relation to events.

    React( настроить ThreeJS ( configure ThreeJS ), показать заставку ( show splash screen )等)是带有缩进的行,表示它们与事件的关系。

Thus, when starting the game (начало event) we configure ThreeJS (настроить ThreeJS reaction), show splash screen (показать заставку reaction), and so on. The class had almost an empty последовательность module in the beginning; only events were present:

因此,在开始游戏( начало事件)时,我们配置ThreeJS( настроить ThreeJSReact),显示初始屏幕( показать заставкуReact)等。 该课程开始时几乎没有一个空的последовательность模块; 仅存在事件:

Events

I have duplicated these same events onto the board, leaving free space to add reactions later during the class (I used GIMP to depict free space in the following image):

我已经将这些相同的事件复制到了黑板上,并在课堂上稍后留下了可用空间来增加React(我使用GIMP在下图中描绘了可用空间):

Board events

We were searching for reactions in память.реакции module (memory.reactions):

我们正在память.реакции模块( memory.reactions )中搜索React:

Reactions

Each reaction of последовательность module is represented in память.реакции module by constructor functions. For example, проверить окончание reaction (check for ending) has a uniquely corresponding ПроверитьОкончание function (CheckForEnding):

的各Reactпоследовательность模块被表示память.реакции由模块构造函数 。 例如, проверить окончаниеReact( check for ending )具有唯一对应的ПроверитьОкончание函数( CheckForEnding ):

function ПроверитьОкончание(мир) // 1.
{
    мир.состояние["скрыто сфер"] = 0; // 2.
    this.исполнить = function() // 3.
    {
        мир.состояние["скрыто сфер"] += 2; // 4.
        var скрыто = мир.состояние["скрыто сфер"]; // 5.
        var сфер = мир.состояние["сферы"].length; // 6.
        if (сфер == скрыто) // 7.
        {
            мир.события["конец"].уведомить(); // 8.
        }
    };
}

The same code in English would look like this:

相同的英文代码如下所示:

function CheckForEnding(world) // 1.
{
    world.state["spheres hidden"] = 0; // 2.
    this.run = function() // 3.
    {
        world.state["spheres hidden"] += 2; // 4.
        var hidden = world.state["spheres hidden"]; // 5.
        var spheres = world.state["spheres"].length; // 6.
        if (spheres == hidden) // 7.
        {
            world.events["ending"].report(); // 8.
        }
    };
}

Let's look closer:

让我们仔细看看:

  1. The function accepts world (dictionary) that is used by functions to communicate with each other. world consists of three regions (dictionary keys):

    函数接受函数用来相互通信的world (词典)。 world由三个区域(字典键)组成:

    • state contains variable data used for communication;

      state包含用于通信的变量数据;

    • settings contain constants to configure functions;

      settings包含用于配置功能的常量;

    • events contain publishers to be able to subscribe functions to events.

      events包含发布者 ,以便能够为事件订阅功能。

  2. An instance of this constructor function is created with new operator while parsing последовательность module. Practically, everything outside of run method is considered to be part of the constructor body. In our case, we create spheres hidden variable to count hidden spheres.

    在解析последовательность模块时,使用new运算符创建了该构造函数的实例。 实际上, run方法之外的所有内容都被认为是构造函数主体的一部分。 在我们的例子中,我们创建spheres hidden变量来计算隐藏球。

  3. run method is executed each time an event is reported.

    每次报告事件时都会执行run方法。

  4. Since check for ending reaction is executed each time a user hides a pair of spheres, we increase spheres hidden counter by 2.

    由于每次用户隐藏一对球体时都会执行check for endingReactcheck for ending ,因此我们将spheres hidden计数器增加2

  5. Just a shorter alias for spheres hidden counter.

    只是spheres hidden计数器的别名较短。

  6. Count the number of spheres at the playing field.

    计算运动场上的球体数量。
  7. Compare the number of spheres at the playing field with the number of hidden spheres.

    将运动场上的球体数量与隐藏的球体数量进行比较。
  8. Report ending event if they are equal, i.e., if all spheres were hidden.

    如果它们相等,即所有球体都被隐藏,则报告ending事件。

Students took turns searching for functions in память.реакции module:

学生轮流在память.реакции模块中搜索功能:

  • a student looks for a function in the module (to simplify the process, I've split the functions with // // // // symbols);

    一个学生在模块中寻找功能(为简化过程,我用// // // //符号分割了功能);

  • once a function is located, the student speaks the name of the function out loud and comes to the board;

    找到功能后,学生会大声说出功能名称,然后登上董事会;
  • the student writes the name down on the board to the list of found functions (students may use any means to remember the names except teacher's hints).

    学生将名字写在黑板上找到的功能列表中(学生可以用任何方式记住名字,除了老师的提示外)。

Such an exercise also highlights who's actively tracking the functions and who's unable to find the next function when it's their turn.

这样的练习还突出显示了谁在积极跟踪功能,而轮到他们时却找不到下一个功能。

Once the names of all functions have been written on the board, we were mapping reactions (functions) to events in a similar fashion:

一旦所有功能的名称写在板上,我们就以类似的方式将React(功能)映射到事件:

  • a teacher asks, for example, which of the listed functions is suitable for event начало

    例如,老师问哪个列出的功能适合事件начало

  • if a student answers correctly, the student

    如果学生回答正确,则该学生

    • comes to the board

      来到董事会
    • writes the reaction under the related event

      写下相关事件下的React
    • crosses corresponding function out of the listed functions

      越过列出的功能中的相应功能

Once we have a more-or-less working set of reactions for an event it's time to transfer them from the board to student PCs. That way we managed to fill the board with reactions both on the board:

一旦我们对某个事件有了或多或少的React,就可以将它们从董事会转移到学生PC上了。 这样,我们就可以在董事会上同时做出React:

Board sequence
Board functions

and in the tool:

并在工具中:

Sequence

The following classes

以下课程

During the following classes, we were trying to create a new reaction and a corresponding constructor function. First, I tried to put a solution into heads quickly (providing complete lines of code); however, that didn't work. That's why we ended up with learning the following code, which took us several classes:

在以下课程中,我们试图创建一个新的React和一个对应的构造函数。 首先,我尝试快速解决问题(提供完整的代码行); 但是,那没有用。 这就是为什么我们最终学习以下代码的原因,该代码带给我们几个类:

var кот = "9";
console.log(кот);

Unfortunately, these two lines of code were hard to explain: students were confused with the concept of variables and their values. This wasn't the only problem: the new function required the use of an array, which I failed to explain at all. There's a long road ahead of me before I'm able to explain variables and arrays to students.

不幸的是,这两行代码很难解释:学生对变量及其值的概念感到困惑。 这不是唯一的问题:新函数需要使用数组,我完全无法解释。 在我能够向学生解释变量和数组之前,我还有很长的路要走。

Of course, by the end of the course we managed to complete the new function, however, I haven't seen understanding and subsequent faith in themselves, which usually manifests itself with a burning enthusiasm we saw in the seventh class.

当然,到本课程结束时,我们设法完成了新功能,但是,我还没有看到对自己的理解和对自己的信任,这通常以我们在第七堂课中看到的热情表现出来。

The last class

最后一堂课

The last class was not using the famous greeting circle at the beginning. Instead, I asked everyone (including myself) to tell what was good (+) and what was bad (-) during the course. Here's the table I got:

最后一堂课开始时没有使用著名的问候圈。 相反,我要求所有人(包括我自己)在课程中说出什么是好(+)和什么是坏(-)。 这是我得到的桌子:

Retro

The same table in English would look like this:

英文的同一表格如下所示:

+-
1Personalized ending screenTouchpad?
2Working on PCWriting on the board
3ExplanationDiscipline
4Flexible learning programSometimes unclear and uninteresting
5There's a finished gameLearning program is too big
6A detailed explanation of algorithmsDoing the same thing each time
7TeamworkStudents of disparate skill level
8Interesting / DifficultToo early
9SequenceHalf of the course
+ --
1个 个性化的结束画面 触摸板?
2 在电脑上工作 在黑板上写
3 说明 学科
4 灵活的学习计划 有时不清楚和无趣
5 有一个完成的游戏 学习程序太大
6 算法的详细说明 每次都做同样的事情
7 团队合作 技能水平各异的学生
8 有趣/困难 太早了
9 序列 一半的课程

Surprisingly enough, the folks didn't like to write on the board even though it greatly increased the efficiency of teaching. On the one hand, the "learning program was too big", on the other hand, we were "doing the same thing each time", i.e. repeating what we have learned before.

出乎意料的是,即使这大大提高了教学效率,人们也不愿意在黑板上写字。 一方面,“学习计划太大”,另一方面,我们“每次都做同样的事情”,即重复以前学到的东西。

We were saving the game to GitHub from time to time. This was difficult, too: we were spending half an hour while students were authenticating. As always, nobody remembered their passwords (each time), others had to verify it's really them accessing GitHub account on a new device, which required access to e-mail, which sometimes belonged to parents (the folks had to call their parents).

我们不时将游戏保存到GitHub。 这也很困难:在学生进行身份验证时,我们花了半个小时。 像往常一样,没有人(每次)都记得他们的密码,其他人则必须验证这是他们确实在新设备上访问GitHub帐户,该帐户需要访问电子邮件,该电子邮件有时属于父母(人们不得不给父母打电话)。

Nonetheless, each student had its own version of the game by the end of the course with personalized beginning and ending screens:

尽管如此,每个学生在课程结束时都有自己的游戏版本,并带有个性化的开始和结束屏幕:

Addr

Conclusion

结论

On the one hand, we had significant success:

一方面,我们取得了巨大的成功:

  • the tool worked as unpretentiously as expected;

    该工具发挥了预期的毫不掩饰的作用;
  • the concept of sequences was easily understood.

    序列的概念很容易理解。

On the other hand, we had an evident failure:

另一方面,我们有一个明显的失败:

  • the tool wasn't friendly to students without JavaScript knowledge, i.e., everyone;

    该工具对没有JavaScript知识的学生(即每个人)都不友好。
  • the teaching program has been stuck most of the time.

    教学计划大部分时间都停滞了。

That's why I'll try to answer the following questions when teaching in 2020:

这就是为什么我在2020年教书时会尝试回答以下问题的原因:

  1. Will another language (Python, Lua) be simpler to explain and work with?

    另一种语言(Python,Lua)会更易于解释和使用吗?
  2. Is it possible to hide Git inside the tool so that one could save the game to Git without leaving the tool?

    是否可以将Git隐藏在工具中,以便无需离开工具就可以将游戏保存到Git中

  3. Is it possible to create API as declarative as SwiftUI?

    是否可以创建与SwiftUI一样的声明性API?

  4. How to explain variables and arrays?

    如何解释变量和数组?

I'll share answers to these and other questions next year ;)

明年,我将分享这些问题的答案;)

Group

翻译自: https://habr.com/en/post/488174/

单片机编程m序列4位程序

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值