一楼放索引
JB_01代码,全灯
#include <SPI.h> void setup() { pinMode (8, OUTPUT); pinMode (9, OUTPUT); pinMode (10, OUTPUT); digitalWrite(8, HIGH); SPI.begin(); digitalWrite(10, LOW); SPI.transfer(0xff); SPI.transfer(0x00); SPI.transfer(0x00); digitalWrite(10, HIGH); digitalWrite(9, LOW); delay(100); } void loop() { delay(100); }
JB_02代码,弱光
#include <SPI.h> void setup() { pinMode (8, OUTPUT); pinMode (9, OUTPUT); pinMode (10, OUTPUT); digitalWrite(8, HIGH); SPI.begin(); digitalWrite(10, LOW); SPI.transfer(0xff); SPI.transfer(0x00); SPI.transfer(0x00); digitalWrite(10, HIGH); analogWrite(9, (byte)(0xff-0x1f)); delay(100); } void loop() { delay(100); }
JB_03代码,对于全透键帽太刺眼了,建议参考02调光代码改进
#include <SPI.h> void setup() { pinMode (8, OUTPUT); pinMode (9, OUTPUT); pinMode (10, OUTPUT); digitalWrite(8, HIGH); SPI.begin(); digitalWrite(10, LOW); SPI.transfer(0x00); SPI.transfer(0xff); SPI.transfer(0xff); digitalWrite(10, HIGH); digitalWrite(9, LOW); delay(100); } void loop() { digitalWrite(10, LOW); SPI.transfer(0x02); SPI.transfer(0xff); SPI.transfer(0xff-0x04); digitalWrite(10, HIGH); delay(1); digitalWrite(10, LOW); SPI.transfer(0x04); SPI.transfer(0xff); SPI.transfer(0xff-0x0E); digitalWrite(10, HIGH); delay(1); }
JB_04代码,简单流水灯
#include <SPI.h> void setup() { pinMode (8, OUTPUT); pinMode (9, OUTPUT); pinMode (10, OUTPUT); digitalWrite(8, HIGH); SPI.begin(); digitalWrite(10, LOW); SPI.transfer(0x00); SPI.transfer(0xff); SPI.transfer(0xff); digitalWrite(10, HIGH); digitalWrite(9, LOW); delay(100); } void loop() { int i; for(i=1;i<256;i*=2) { digitalWrite(10, LOW); SPI.transfer(0xff); SPI.transfer(0xff); SPI.transfer((byte)(0xff-i)); digitalWrite(10, HIGH); delay(50); } for(i=1;i<256;i*=2) { digitalWrite(10, LOW); SPI.transfer(0xff); SPI.transfer((byte)(0xff-i)); SPI.transfer(0xff); digitalWrite(10, HIGH); delay(50); } }
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 | |
【分享评测,赢取加热台】使用8051单片机驱动WS2812被打赏40分 |