论坛风格切换切换到宽版
  • 8543阅读
  • 33回复

arduino 玩起来了 [复制链接]

上一主题 下一主题
离线BG7YMX
发帖
3464
只看该作者 20楼 发表于: 2013-09-24
用户被禁言,该主题自动屏蔽!
[ 此帖被BG7YMX在2013-09-24 13:13重新编辑 ]
本主题包含附件,请 登录 后查看, 或者 注册 成为会员
离线BG7YMX
发帖
3464
只看该作者 21楼 发表于: 2013-09-24
用户被禁言,该主题自动屏蔽!
离线BG3UBC
发帖
2481
只看该作者 22楼 发表于: 2013-09-24
回 yyh 的帖子
yyh:这个实验了,没得问题,三轴和磁角度的都行 (2013-09-24 12:21) 

用什么显示屏?
bg3ubc.taobao.com 也许有你需要的
离线BG6JJI
发帖
4942
只看该作者 23楼 发表于: 2013-09-24
回 BG3UBC 的帖子
BG3UBC:用什么显示屏?
 (2013-09-24 17:22) 

想简单就用I2c 1602
到处游荡的机器人火腿,目前在丽江
RIG:我有一堆uSDX
ANT:随时都能抄走的拉杆GP天线
QQ:1416160    我的DIY群:777353770
http://www.dxsummit.fi/DxSpots.aspx
离线yyh
发帖
1403
只看该作者 24楼 发表于: 2013-09-24
回 BG3UBC 的帖子
BG3UBC:用什么显示屏?
 (2013-09-24 17:22) 

串口通信,显示屏直接用库就是了
BG8BAL
离线电离层
发帖
5854
只看该作者 25楼 发表于: 2013-09-25
离线BG3UBC
发帖
2481
只看该作者 26楼 发表于: 2013-09-25
回 yyh 的帖子
yyh:串口通信,显示屏直接用库就是了 (2013-09-24 23:32) 

你能够给提供个技术指导不?我也买你这样的模块,我就要测方向模块和显示模块
bg3ubc.taobao.com 也许有你需要的
离线BG6JJI
发帖
4942
只看该作者 27楼 发表于: 2013-09-25
回 BG3UBC 的帖子
BG3UBC:你能够给提供个技术指导不?我也买你这样的模块,我就要测方向模块和显示模块 (2013-09-25 08:47)

http://item.taobao.com/item.htm?spm=a230r.1.14.11.flp0V0&id=15807019364&initiative_new=1  显示屏
http://item.taobao.com/item.htm?spm=a1z10.3.w1017-2403345377.10.oy4pHn&id=15247191214&   陀螺仪

都是I2C的,接线简单,程序编写简单
[ 此帖被BG6JJI在2013-09-25 09:58重新编辑 ]
到处游荡的机器人火腿,目前在丽江
RIG:我有一堆uSDX
ANT:随时都能抄走的拉杆GP天线
QQ:1416160    我的DIY群:777353770
http://www.dxsummit.fi/DxSpots.aspx
离线BG6JJI
发帖
4942
只看该作者 28楼 发表于: 2013-09-25
到处游荡的机器人火腿,目前在丽江
RIG:我有一堆uSDX
ANT:随时都能抄走的拉杆GP天线
QQ:1416160    我的DIY群:777353770
http://www.dxsummit.fi/DxSpots.aspx
离线yyh
发帖
1403
只看该作者 29楼 发表于: 2013-09-25
回 BG3UBC 的帖子
BG3UBC:
你能够给提供个技术指导不?我也买你这样的模块,我就要测方向模块和显示模块

这个实验了,没得问题,三轴和磁角度的都行
给你个库文件包,你减压后放在libraries文件夹下面,然后开启软件,就可以在例子程序里看到HMC5883L,然后打开下载就可以了,当然你可以删除一些你不需要的变量和打印结果。直接通过串口显示,LCD你就自己参照到例子程序改或者添加到这个程序里都可以,注意引用头文件。



#include <Wire.h>
#include <HMC5883L.h>
HMC5883L compass;
int error = 0;
void setup()
{
  // Initialize the serial port.
  Serial.begin(9600);
  Serial.println("Starting the I2C interface.");
  Wire.begin(); // Start the I2C interface.
  Serial.println("Constructing new HMC5883L");
  compass = HMC5883L(); // Construct a new HMC5883 compass.
    
  Serial.println("Setting scale to +/- 1.3 Ga");
  error = compass.SetScale(1.3); // Set the scale of the compass.
  if(error != 0) // If there is an error, print it out.
    Serial.println(compass.GetErrorText(error));
  
  Serial.println("Setting measurement mode to continous.");
  error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous
  if(error != 0) // If there is an error, print it out.
    Serial.println(compass.GetErrorText(error));
}
// Our main program loop.
void loop()
{
  // Retrive the raw values from the compass (not scaled).
  MagnetometerRaw raw = compass.ReadRawAxis();
  // Retrived the scaled values from the compass (scaled to the configured scale).
  MagnetometerScaled scaled = compass.ReadScaledAxis();
  
  // Values are accessed like so:
  int MilliGauss_OnThe_XAxis = scaled.XAxis;// (or YAxis, or ZAxis)
  // Calculate heading when the magnetometer is level, then correct for signs of axis.
  float heading = atan2(scaled.YAxis, scaled.XAxis);
  
  // Once you have your heading, you must then add your 'Declination Angle', which is the 'Error' of the magnetic field in your location.
  // Find yours here: http://www.magnetic-declination.com/
  // Mine is: 2? 37' W, which is 2.617 Degrees, or (which we need) 0.0456752665 radians, I will use 0.0457
  // If you cannot find your Declination, comment out these two lines, your compass will be slightly off.
  float declinationAngle = 0.0457;
  heading += declinationAngle;
  
  // Correct for when signs are reversed.
  if(heading < 0)
    heading += 2*PI;
    
  // Check for wrap due to addition of declination.
  if(heading > 2*PI)
    heading -= 2*PI;
  
  // Convert radians to degrees for readability.
  float headingDegrees = heading * 180/M_PI;
  // Output the data via the serial port.
  Output(raw, scaled, heading, headingDegrees);
  // Normally we would delay the application by 66ms to allow the loop
  // to run at 15Hz (default bandwidth for the HMC5883L).
  // However since we have a long serial out (104ms at 9600) we will let
  // it run at its natural speed.
  // delay(66);
}
// Output the data down the serial port.
void Output(MagnetometerRaw raw, MagnetometerScaled scaled, float heading, float headingDegrees)
{
   Serial.print("Raw:\t");
   Serial.print(raw.XAxis);
   Serial.print("   ");  
   Serial.print(raw.YAxis);
   Serial.print("   ");  
   Serial.print(raw.ZAxis);
   Serial.print("   \tScaled:\t");
  
   Serial.print(scaled.XAxis);
   Serial.print("   ");  
   Serial.print(scaled.YAxis);
   Serial.print("   ");  
   Serial.print(scaled.ZAxis);
   Serial.print("   \tHeading:\t");
   Serial.print(heading);
   Serial.print(" Radians   \t");
   Serial.print(headingDegrees);
   Serial.println(" Degrees   \t");
   delay(100);
}
[ 此帖被yyh在2013-09-25 13:26重新编辑 ]
本主题包含附件,请 登录 后查看, 或者 注册 成为会员
BG8BAL
离线yyh
发帖
1403
只看该作者 30楼 发表于: 2013-09-27
物联网测试
我的物联网网关:
http://www.lewei50.comwww.lewei50.com/u/g/2216
BG8BAL
离线yyh
发帖
1403
只看该作者 31楼 发表于: 2013-09-27
检测温度、湿度、气压、海拔
我的物联网网关:
http://www.lewei50.comwww.lewei50.com/u/g/2216
本主题包含附件,请 登录 后查看, 或者 注册 成为会员
BG8BAL
离线net2000
发帖
4525
只看该作者 32楼 发表于: 2013-09-27
arduino是意大利文,读作阿尔赌衣落。
离线yyh
发帖
1403
只看该作者 33楼 发表于: 2013-09-27
回 net2000 的帖子
net2000:arduino是意大利文,读作阿尔赌衣落。 (2013-09-27 20:16) 

很好玩哈
BG8BAL