Blog


闪烁的LED灯(LED灯引脚定义)

MWC红色Arduino板(之后的简称Arduino板)上有四个LED灯,分别为LED1~LED4。经过测试,发现其对应的引脚地址为:13,30,31,32. 需要注意:LED1为高电平灯亮,LED2~LED4为低电平灯亮。 pinMode 设置引脚的输入,输出模式; digitalWrite向指定的数字引脚写入值; delay延迟,参数的单位为毫秒。   int LED1 = 13; // HIGH level signal trigger int LED2 = 30; // LOW level signal trigger int LED3 = 31; // LOW level signal trigger int LED4 = 32; // LOW level signal trigger void setup() { // put your setup […]


项目简介- MWC 红板飞控 主控芯片MEGA2560

自己的毕业设计是四轴飞行器的手机控制,需要学习Arduino来编写飞控软件。因此写一系列Arduino开发笔记。一方面帮助自己理解技术知识,一方面帮助可能与我遇到相同问题的人。 我所用的硬件:MWC红板飞控,搭载MEGA2560芯片,板载三轴角速度传感器ITG3205(ITG3200),三轴加速度传感器BMA180,三轴磁罗盘HMC5883,气压计BMP085(9D0F)。


[leetcode] Multiply Strings

Multiply Strings Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. Tags: math, string 字符串相乘,关键是模拟我们平时手算乘法时的过程。取出num2的每一位,乘以num1,再把之前得到的re向左移一位,再加上这个循环中的结果。所以我们需要实现两个函数multiplyNum(字符串乘以数字)和sum(两个字符串相加)。 num1或num2为零需要单独考虑,否则结果会出现类似0000的情况。 class Solution { public: string multiply(string num1, string num2) { int i = 0; string re; if(num1 == “0” […]


[leetcode] Combinations

Combinations Given two integers n and k, return all possible combinations of k numbers out of 1 … n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] tag: backtracking 回溯问题,用递归求解就好。 class Solution { public: vector<vector<int> > combine(int […]


[leetcode] Longest Valid Parentheses

Longest Valid Parentheses Given a string containing just the characters ‘(‘ and ‘)’, find the length of the longest valid (well-formed) parentheses substring. For “(()”, the longest valid parentheses substring is “()”, which has length = 2. Another example is “)()())”, where the longest valid parentheses substring is “()()”, which […]


[leetcode] Next Permutation

Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order). The replacement must be in-place, do not allocate extra memory. Here are some examples. […]