关于gokit2 arduino针脚
收到了gokit2开发板 很高兴 最近需要做个实时监控电压电流的功能所以买了电流电压检测模块接上a0 a1 gnd针脚用智能宠物屋的2.2程序 修改后 发现数值输出有问题 空载时 数值 不为0
不知道怎么办~
#include <DHT.h>
#include <I2Cdev.h>
#include <MemoryFree.h>
#include <MsTimer2.h>
#include <SSD1306.h>
#include <ChainableLED.h>
#include <Arduino.h>
#include <SoftwareSerial.h>
#include "Wire.h"
#include "GoKit.h"
#define VT_PIN A0 //connect with VT
#define AT_PIN A1 //connect with AT
#define ARDUINO_WORK_VOLTAGE 5.0 //work voltage of Arduino
#define OLED_DC 9
#define OLED_CS 10
#define OLED_CLK 13
#define OLED_MOSI 11
#define OLED_RESET 8
#define RGB_LED_ENA1
SSD1306 oled(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
void setup()
{
Serial.begin(9600); // 打开串口,设置波特率为9600 bps
Serial.println("Voltage(V) / Current(A) ");
GoKit_Init();
pinMode(RGB_LED_EN,OUTPUT);
digitalWrite(RGB_LED_EN,HIGH);
oled.ssd1306_init(SSD1306_SWITCHCAPVCC);
oled.drawstring(0,3," Hello World! ");
oled.display();
#if (DEBUG==1)
Serial.println("GoKit initOK!");
Serial.print("freeMemory()=");
Serial.println(freeMemory());
#endif
}
void loop()
{
int vt_temp = analogRead(VT_PIN);
int at_temp = analogRead(AT_PIN);
double voltage = vt_temp * (ARDUINO_WORK_VOLTAGE / 1023.0) * 5;
double current = at_temp * (ARDUINO_WORK_VOLTAGE / 1023.0);
Serial.print(voltage); Serial.print('/'); Serial.println(current);
delay(1000);
GoKit_Handle();
}
页:
[1]