| |
— | learing:examples:main [2023/06/07 04:23] (当前版本) – 创建 - 外部编辑 127.0.0.1 |
---|
| ====== 例程 ====== |
| |
| 下面的例子是一些核心功能和扩展库的概述。 |
| |
| ===== 核心功能 ===== |
| |
| 使用核心功能,需要懂基本语法来进行一些简单的编程。 |
| |
| 以下例程,在IDE的"文件"---“示例"菜单中可以直接打开。 |
| <WRAP center round box 100%> |
| ==== 1.基础 ==== |
| |
| |
| * [[zh:learing:exemples:BareMinimum|BareMinimum]]: 程序运行所必须的代码. |
| * [[zh:learing:exemples:Blink|Blink]]: 单LED闪烁. |
| * [[zh:learing:exemples:DigitalReadSerial|DigitalReadSerial]]: 读取开关状态,输出状态信息到串口监视器. |
| * [[zh:learing:exemples:AnalogReadSerial|AnalogReadSerial]]: 读取电位状态,输出状态信息到串口监视器. |
| * [[zh:learing:exemples:Fade|Fade]]: 用模拟输出调节LED亮度. |
| * [[zh:learing:exemples:ReadAnalogVoltage|ReadAnalogVoltage]] : 读取模拟输入电压,输出电压到串口监视器. |
| </WRAP> |
| |
| <WRAP center round box 100%> |
| ==== 2.数字 ==== |
| |
| |
| * [[zh:learing:exemples:BlinkWithoutDelay|Blink Without Delay]]: 不使用delay来使LED闪烁。 |
| * [[zh:learing:exemples:Button|Button]]: 使用一个按钮来控制LED。 |
| * [[zh:learing:exemples:Debounce|Debounce]]: 获取按钮状态,过滤噪音。 |
| * [[zh:learing:exemples:ButtonStateChange|Button State Change]]: 统计按钮按下次数。 |
| * [[zh:learing:exemples:InputPullupSerial|Input Pullup Serial]]: 演示pinMode()使用INPUT_PULLUP参数。 |
| * [[zh:learing:exemples:Tone|Tone]]: 使用压电扬声器播放一段旋律。 |
| * [[zh:learing:exemples:Pitch follower|Pitch follower]]: 使用模拟输入控制扬声器音高。 |
| * [[zh:learing:exemples:Simple Keyboard|Simple Keyboard]]: 基于3个压力传感器与扬声器的音乐键盘。 |
| * [[zh:learing:exemples:Tone4|Tone4]]:在多个扬声器上使用tone功能连续播放不同音乐 |
| |
| </WRAP> |
| <WRAP center round box 100%> |
| ==== 3.模拟 ==== |
| |
| |
| * [[zh:learing:exemples:AnalogInOutSerial|AnalogInOutSerial]]: 读取一个模拟输入,映射结果,使用映射的结果驱动LED变亮或者变暗。 |
| * [[zh:learing:exemples:AnalogInput|Analog Input]]: 使用电位计控制让LED闪烁 |
| * [[zh:learing:exemples:AnalogWriteMega|AnalogWriteMega]]:使用OCROBOT MEGA 板使12个LED一个个变色 |
| * [[zh:learing:exemples:Calibration|Calibration]]: 为期望得到的模拟传感器值定义最大最小值 |
| * [[zh:learing:exemples:Fading|Fading]]: 使用PWM使LED变色 |
| * [[zh:learing:exemples:Smoothing|Smoothing]]: 平滑模拟输入端的多个数据 |
| |
| </WRAP> |
| |
| <WRAP center round box 100%> |
| ==== 4.通讯 ==== |
| |
| |
| 这些例程包含了使用OCROBOT和PROCESSING通讯的代码. 详见processing.org。 |
| * [[zh:learing:exemples:ReadASCIIString|ReadASCIIString]]:分析输入端的以逗号分隔的字符串来使LED变色 |
| * [[zh:learing:exemples:ASCIITable|ASCII Table]]: 使用 OCROBOT的高级串口输出功能 |
| * [[zh:learing:exemples:Dimmer|Dimmer]]: 移动鼠标来改变LED亮度 |
| * [[zh:learing:exemples:Graph|Graph]]: 发送数据到电脑通过Processing把它画出来 |
| * [[zh:learing:exemples:PhysicalPixel|Physical Pixel]]: 从processing发送数据到arduino来使LED亮灭. |
| * [[zh:learing:exemples:SerialCallResponse|Serial Call Response]]: 使用握手协议发送变量. |
| * [[zh:learing:exemples:SerialEvent|SerialEvent]]: 演示SerialEvent()的使用. |
| * [[zh:learing:exemples:Midi|MIDI]]: 连续发送MIDI音符. |
| </WRAP> |
| |
| |
| |
| <WRAP center round box 100%> |
| ==== 5.控制 ==== |
| |
| |
| * [[zh:learing:exemples:IfStatement|If Statement (Conditional)]]: 使用if声明来基于输入条件改变输出状态 |
| * [[zh:learing:exemples:ForLoop|For Loop]]: 使用for loop控制多路LED |
| * [[zh:learing:exemples:Array|Array]]: for循环中的变量演示了数组的用法 |
| * [[zh:learing:exemples:WhileLoop|While Loop]]: 当读取到按键信息后,使用while循环来校准传感器 |
| * [[zh:learing:exemples:SwitchCase2|Switch Case 2]]: 基于串口接收到的字符作出不同的反应 |
| |
| |
| </WRAP> |
| <WRAP center round box 100%> |
| ==== 6. 字符串 ==== |
| |
| * [[zh:learing:exemples:Character Analysis|Character Analysis]]: 使用运算符来识别字符类型 |
| * [[zh:learing:exemples:String Addition Operator|String Addition Operator]]:多种将字符串合并的方法 |
| * [[zh:learing:exemples:String Append Operator|String Append Operator]]:使用+=运算符和 concat() 方法向字符串添加别的东西 |
| * [[zh:learing:exemples:String Case Changes|String Case Changes]]:改变字符的大小写 |
| * [[zh:learing:exemples:String Characters|String Characters]]:找到字符串里的字符 |
| * [[zh:learing:exemples:String Comparison Operators|String Comparison Operators]]: 比较字符串 |
| * [[zh:learing:exemples:String Constructors|String Constructors]]:初始化字符串对象. |
| * [[zh:learing:exemples:String Index Of|String Index Of]]:在字符串里寻找字符对象 |
| * [[zh:learing:exemples:String Length & String Length Trim|String Length & String Length Trim]]:去除空格符. |
| * [[zh:learing:exemples:String Replace|String Replace]]:替换字符串里的单个字符 |
| * [[zh:learing:exemples:String Start With Ends With|String Start With Ends With]]:检查字符串的起始符或者结束符. |
| * [[zh:learing:exemples:String Substring|String Substring]]:在给定的字符串里寻找短语 |
| * [[zh:learing:exemples:String To Int|String To Int]]:转换字符串为整型数字 |
| |
| </WRAP> |
| <WRAP center round box 100%> |
| ==== 7.传感器 ==== |
| |
| |
| * ADXL3xx: Read an ADXL3xx accelerometer. |
| * Knock: Detect knocks with a piezo element. |
| * Memsic2125 : Two-axis acceleromoter. |
| * Ping: Detecting objects with an ultrasonic range finder. |
| </WRAP> |
| <WRAP center round box 100%> |
| |
| ==== 8.显示 ==== |
| |
| |
| * Examples of basic display control |
| * LED Bar Graph: How to make an LED bar graph. |
| * Row Column Scanning: How to control an 8x8 matrix of LEDs. |
| </WRAP> |
| |
| |
| |