使用Arduino,我创建了一个二维数组,其十六进制数字0-F显示在七段显示器上。一切工作正常,我使用了for循环使显示屏的每个部分都打开,但是顶部显示屏(A)始终处于打开状态,即使不应打开。
void sevenSegment(int a) {
for (int i = 0; i < nPins; i++) {
digitalWrite(fontArray[a][i], HIGH);
}
}
数组:
int fontArray[][7] = {
{13, 12, 11, 10, 9, 8}, // 0
{12, 11}, // 1
{13, 12, 10, 9, 7}, // 2
{13, 12, 11, 10, 7}, // 3
{12, 11, 8, 7}, // 4
{13, 11, 10, 8, 7}, // 5
{13, 11, 10, 9, 8, 7}, // 6
{13, 12, 11}, // 7
{13, 12, 11, 10, 9, 8, 7}, // 8
{13, 12, 11, 10, 8, 7}, // 9
{13, 12, 11, 9, 8, 7}, // A
{11, 10, 9, 8, 7}, // B
{13, 10, 9, 8}, // C
{12, 11, 10, 9, 7}, // D
{13, 10, 9, 8, 7}, // E
{13, 9, 8, 7} }; // F
为什么显示屏的顶部(A)的插针13始终在燃烧? :/
答案 0 :(得分:1)
这些段永远不会设置回url: www.google.de
This is the data we get back from yourUrl: www.google.de - DATA/DATA/DATA
。
您将需要以下内容:
Option Explicit
Sub CallRangeL_Urls()
Dim iCell As Range
Dim targetRange As Range
Dim Sheet1 As Worksheet
Set Sheet1 = ActiveSheet
For Each iCell In Sheet1.Range("L4:L4")
'create a new "RESULTS" sheets
Sheets.Add after:=Sheets(1)
Debug.Print "New sheet created: " & ActiveSheet.Name
'set a link on the sheet
Range("A1").Value = iCell.Value 'leave a copy of the url on the sheet as a reference
Set targetRange = Range("A3") 'here we want to get the results
Call ImportData(iCell.Value, targetRange)
Next iCell
End Sub
Sub ImportData(urlToOpen As String, target As Range)
Dim datavalue1, datavalue2, datavalue3
'...
datavalue1 = "data value 1"
datavalue2 = "data value 2"
datavalue3 = "data value 3"
'Save whatever data to the new sheet
target.Offset(0, 0).Value = datavalue1 'Range("A3")
target.Offset(1, 0).Value = datavalue2 'Range("A4")
target.Offset(2, 0).Value = datavalue3 'Range("A5")
Debug.Print "datavalues stored on sheet: " & target.Parent.Name
'...
End Sub
然后使用:
New sheet created: Sheet2
datavalues stored on sheet: Sheet2
如果引脚号不连续,则可以使用第二个数组,如下所示:
$date = array();
$date['date'] = 1554328800;
$date['events'] = array(130, 131, 163);
$date['tags'] = array(4, "1,3,4", "1,3");
$events_by_tag = array(); //gather events grouped by tag
foreach ($date['events'] as $pos => $event) { //parse all events
if (is_string($date['tags'][$pos])) { //if tag is a string <=> if there are more than one tag for the current event
$tags = explode(',', $date['tags'][$pos]); //explode string to loop over the tags
foreach ($tags as $tag) {
if (is_array($events_by_tag[$tag])) { //if tag has already been found and then an array exists to store it
array_push($events_by_tag[$tag], $event);
} else {
$events_by_tag[$tag] = array($event); //else create an array for the next times this tag will be found and store it inside
}
}
} else { //if there's a single tag which is a integer
if (is_array($events_by_tag[$tag])) { //if tag has already been found and then an array exists to store it
array_push($events_by_tag[$date['tags'][$pos]], $event);
} else {
$events_by_tag[$date['tags'][$pos]] = array($event); //else create an array for the next times this tag will be found and store it inside
}
}
}
$result_array = array(); //final array reorganized + date
foreach ($events_by_tag as $tag => $events) {
$tmp_array['date'] = $date['date'];
$tmp_array['events'] = $events;
$tmp_array['tags'] = $tag;
array_push($result_array, $tmp_array);
}
答案 1 :(得分:-1)
由于接线错误,数组fontArray
并未明确初始化所有值。因此,编译器将为这些未初始化的值(在全局数组中)提供默认值0。
结果是调用digitalWrite(0, HIGH)
。根据板卡和引脚配置的不同,引脚“ 0”可能会映射到13。
可以使用以下方式编写for循环来防止这种情况:
for (int i = 0; i < nPins; i++) {
int pin = fontArray[a][i];
if (pin == 0) {
break;
}
digitalWrite(pin, HIGH);
}