我最近在阅读关于Arduino的Hello World应用程序的文章,我心里想,"我想知道我是否可以用我现在拥有的硬件做到这一点."
由于我没有Arduino,我抓起了一个我已经铺设的USB闪存驱动器并开始在谷歌上搜索有关它的信息.我在这方面没有找到太多有用的信息,所以我现在在这里问:我是否可以访问USB驱动器的硬件(例如LED)并通过某些编程环境与它进行交互(我当时认为C#应该可能有办法做到这一点)?
此外,与此主题相关 - 有谁知道USB驱动器使用什么样的命令?例如,SCSI存储设备具有标准化的命令集; ATA设备具有类似的协议.如何向USB存储设备发出简单的读/写命令?
需要使用C#或VB.net使键盘的LED(大写锁定/数字锁定或滚动锁定LED)闪烁.(有或没有使用互操作是好的)
我有一个RGB LED,其引脚分别为9,10,11和一个接地引脚.已为R,G和B提供电阻器.
当我做:
analogWrite(r, 255); // I see a red color
analogWrite(g, 0);
analogWrite(b, 0);
analogWrite(r, 0);
analogWrite(g, 255); // I see a green color
analogWrite(b, 0);
analogWrite(r, 0);
analogWrite(g, 0); // I see a blue color
analogWrite(b, 255);
Run Code Online (Sandbox Code Playgroud)
当我做:
analogWrite(r, 153);
analogWrite(g, 102);
analogWrite(b, 51);
Run Code Online (Sandbox Code Playgroud)
它看起来并不棕色,更像是蓝色.我错过了我需要做的事情吗?
/*
Button
Turns on and off a light emitting diode(LED) connected to digital
pin 13, when pressing a pushbutton attached to pin 2.
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached to pin 2 from +5V
* 10K resistor attached to pin 2 from ground
* Note: on most Arduinos there is already an LED on the board
attached to pin 13.
created 2005
by DojoDave <http://www.0j0.org>
modified 30 Aug 2011
by Tom Igoe
This …Run Code Online (Sandbox Code Playgroud) 是否可以在Android设备上以编程方式禁用和启用LED指示灯?我并不是指在通知中打开和关闭它.我没有在api中看到任何会这样做的东西.我猜这是硬件特定的,如果可能的话.
很多硬件都附带一个Tx/Rx状态LED,但如果您的硬件没有,并且您想查看数据是否正在传输,该怎么办?如果您只是将LED设置为线的值,它可能会在您看到之前打开和关闭(<1/100秒).
我的问题是,如何编写中断驱动功能来驱动LED状态?我搜索了互联网,什么都没找到,我可以使用一个模数计数器,但这看起来很笨重.还有其他想法吗?
PS - 我想在Arduino或Mbed中使用它,但我怀疑它对于哪一个问题有所不同......
我正在尝试setLightColor使用从 JavaScript 界面返回的颜色进行更改。不幸的是,NotificationCompat.Builder(context, CHANNEL_ID).setLights对 API >= 26 绝对没有影响,所以我不能使用Intent.putExtra或任何类似的东西。
设置好之后还能修改吗?我希望它是动态的。
编辑似乎对我想要的东西有一些误解。我不想碰Broadcast Reciever. 它工作得很好。我想更改通知渠道。它没有更新setLightColor(Color.___)。
在 protected void onCreate
String jobColor = someColor; // Will be filled in by other code - different colour every time
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = "Channel_Name";
String description = "Channel_Description";
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
channel.setDescription(description);
channel.enableLights(true);
channel.setLightColor(Color.parseColor(jobColor)); // Dynamically set from above
channel.enableVibration(true);
NotificationManager notificationManager = …Run Code Online (Sandbox Code Playgroud) 我使用C++和OpenCV从10x11 LED阵列的轮廓中提取了110个坐标,并将它们存储在矢量中.现在我想从左上角到右下角对它们进行排序,以检测某个行和列中的LED是否亮起.我通过y位置预先排列坐标,以确保向量中的前10个坐标代表我的图像中的第一个LED行.
vector<Point2f> centers;
bool compareY(Point2f p1, Point2f p2){
if(p1.y < p2.y) return true;
if(p1.y > p2.y) return false;
}
sort(centers.begin(), centers.end(), compareY);
Run Code Online (Sandbox Code Playgroud)
现在我必须按x位置对它们进行排序.问题在于来自第二行或任何其他行中的第一个LED的x位置可以比第一行中的第一个LED小一点.由于这个事实,他们必须从中心[0]到中心[9],中心[10]到中心[20] ......逐行排序.有人知道怎么做吗?
提前致谢!
编辑:管理对点进行排序,但我的基于轮廓检测的算法不够健壮,无法检测所有LED.有没有人想要一个强大的方法来检测它们?
所以我有一个蓝牙模块,我已经创建了一些代码,所以当我按下按钮1它打开LED时,当我按2它关闭LED时,3应该让LED持续闪烁.一切都运行得很好,除了当我按3次LED闪烁一次然后停止.我可以对代码做什么让它连续闪烁,直到我再次按下按钮1或2?
char LED = 0;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600); // Opens Serial port
}
void loop() {
if (Serial.available()> 0){
LED = Serial.read();
Serial.print(LED);
if (LED == '1')
digitalWrite(13, HIGH);
if (LED == '0')
digitalWrite(13, LOW);
if (LED == '3') {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
}
}
Run Code Online (Sandbox Code Playgroud)