Решил поэкспериментировать с китайским клоном Arduino Uno. Написал код имитации синусоиды:
Код: Выделить всё
const int analogOutPin = A0;
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
int i;
for (i=0; i<1024; ++i)
analogWrite (analogOutPin, i);
for (i=1023; i>0; --i)
analogWrite (analogOutPin, i);
}Этап 2.
Соединил перемычкой выводы А0 и А1. Написал такой код, чтобы посмотреть вывод.
Код: Выделить всё
const int analogOutPin = A0;
const int analogInPin = A1;
void setup() {
pinMode (analogOutPin, OUTPUT);
pinMode (analogInPin, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int i, j;
for (i=0; i<1024; ++i)
{
analogWrite (analogOutPin, i);
delay (100);
j = analogRead (analogInPin);
if (i != j)
{
Serial.print("OutLevel = ");
Serial.print(i);
Serial.print("\t InLevel = ");
Serial.println(j);
}
}
while (1==1) {}
}Код: Выделить всё
OutLevel = 120 InLevel = 0
OutLevel = 121 InLevel = 0
OutLevel = 122 InLevel = 0
OutLevel = 123 InLevel = 0
OutLevel = 124 InLevel = 0
OutLevel = 125 InLevel = 0
OutLevel = 126 InLevel = 0
OutLevel = 127 InLevel = 0
OutLevel = 128 InLevel = 1023
OutLevel = 129 InLevel = 1023
OutLevel = 130 InLevel = 1023
OutLevel = 131 InLevel = 1022
OutLevel = 132 InLevel = 1023
OutLevel = 133 InLevel = 1023
OutLevel = 134 InLevel = 1023
OutLevel = 135 InLevel = 1023
OutLevel = 136 InLevel = 1023


