查看: 9655|回复: 19

基于arduino的手持示波器V0.1

[复制链接]
  • TA的每日心情
    慵懒
    2019-4-17 21:21
  • 签到天数: 29 天

    [LV.4]偶尔看看III

    发表于 2012-9-5 21:45 | 显示全部楼层 |阅读模式
    本帖最后由 珜羽 于 2012-9-7 20:36 编辑

    二话不说,先看看效果:


    程序只完成了信号触发采集,上升沿,下降沿触发。采集并显示部分。外围电路没有做,而且没有设置按钮。。。

    代码如下:哪有热心有爱的同学帮忙加下注释吧。

    #include "Lcd12864.h"
    #include  "SPI.h"
    unsigned char bmp[1024]={//在内存里面开辟1K显存
      0x00,0x00,0x00,0xE0,0xE0,0x9E,0x9E,0xE0,0xE0,0x00,0x00,0x00,0x00,0xE0,0xE0,0x60,
      0x60,0x00,0x00,0x80,0x80,0x60,0x60,0x60,0x60,0xFE,0xFE,0x00,0x00,0xE0,0xE0,0x00,
      0x00,0xE0,0xE0,0x00,0x00,0xE6,0xE6,0x00,0x00,0xE0,0xE0,0x60,0x60,0x80,0x80,0x00,
      0x00,0x80,0x80,0x60,0x60,0x60,0x60,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x1E,0x1E,0x01,0x01,0x01,0x01,0x01,0x01,0x1E,0x1E,0x00,0x00,0x1F,0x1F,0x00,
      0x00,0x00,0x00,0x07,0x07,0x18,0x18,0x18,0x18,0x1F,0x1F,0x00,0x00,0x07,0x07,0x18,
      0x18,0x1F,0x1F,0x00,0x00,0x1F,0x1F,0x00,0x00,0x1F,0x1F,0x00,0x00,0x1F,0x1F,0x00,
      0x00,0x07,0x07,0x18,0x18,0x18,0x18,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x40,0x40,0x80,0x80,0x00,0x00,
      0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
      0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
      0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
      0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
      0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
      0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
      0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
      0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x09,0x05,0x05,0x03,0x03,0x01,0x01,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x10,0x10,0x10,0x10,
      0x10,0x10,0xE0,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x00,
      0x00,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x80,0x00,
      0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x80,
      0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x10,0x10,0x10,0x10,
      0x10,0x10,0x0F,0x00,0x7F,0x10,0x10,0x10,0x10,0x0F,0x00,0x0F,0x12,0x12,0x12,0x0B,
      0x00,0x1F,0x01,0x00,0x00,0x00,0x1F,0x00,0x0C,0x10,0x10,0x10,0x0F,0x00,0x0F,0x10,
      0x10,0x10,0x08,0x1F,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x7F,
      0x10,0x10,0x10,0x10,0x0F,0x00,0x0F,0x12,0x12,0x12,0x0B,0x00,0x1F,0x00,0x00,0x00
    };
    void setup()
    {
      lcd12864 x;
      x.LcmInit();
      unsigned char x1=0;
      unsigned char y1=17;
      x.PUTBMP(bmp);
      delay(500);
      while(x1<128){
        if((x1/33)&0x01)
        {
          y1--;
        }
        else
        {
          y1++;
        }
        Set_Bit(x1++,y1);   
        x.PUTBMP(bmp);
        delay(3);  
      }
      delay(500);

    }
    void loop()
    {  
      lcd12864 x;
      unsigned char x1;
      unsigned char y1;
      unsigned char ADnow;
      unsigned char ADbf;  
      for(int i=0; i<1024; i++) bmp[i]=0;
      ADbf=255;
      while(1){
        ADnow=analogRead(A0)/4;
        //触发的ADC阙值
        if(ADnow>127)
        {
          //比之前保存的值大,上升沿触发
          if(ADnow>ADbf){
            break;
          }
          else{
            ADbf=ADnow;
          }
        }
      }
      
    //采集128个数据刷新到显存
      for(x1=0;x1<128;x1++)
      {
        y1=analogRead(A0)/16;
        Set_Bit(x1,y1);
      delay(1);  
      }
      x.PUTBMP(bmp);
    //  delay(100);
    }

    void Set_Bit(unsigned char x,unsigned char y)//x=0~127,y=0~63 描点程序
    {
      unsigned char BitVal;
      unsigned int Adrr;
      BitVal=1<<(y%8);
      Adrr=x + y/8*128;
      bmp[Adrr]|=BitVal;
    }

    PS:这个程序需要库的支持。下载地址见:  Arduino教程(提高篇)——驱动12864LCD模块


  • TA的每日心情
    奋斗
    2019-7-12 18:42
  • 签到天数: 48 天

    [LV.5]常住居民I

    发表于 2012-9-5 22:21 | 显示全部楼层
    支持一下

    该用户从未签到

    发表于 2012-9-5 23:26 | 显示全部楼层
    我是小杰啊,顶你哇。。。

    该用户从未签到

    发表于 2012-9-6 08:28 | 显示全部楼层
    非常支持!
  • TA的每日心情
    无聊
    2017-1-24 10:00
  • 签到天数: 10 天

    [LV.3]偶尔看看II

    发表于 2012-9-6 16:29 | 显示全部楼层
    呆呆来学习了~~~原来珜羽是乐乐呀~~~(不是么。。。不是就露怯露大发了)~~~
  • TA的每日心情
    郁闷
    2018-12-6 22:21
  • 签到天数: 48 天

    [LV.5]常住居民I

    发表于 2012-9-6 17:08 | 显示全部楼层
    槑小子 发表于 2012-9-6 16:29
    呆呆来学习了~~~原来珜羽是乐乐呀~~~(不是么。。。不是就露怯露大发了)~~~ ...

    是的
  • TA的每日心情
    无聊
    2017-1-24 10:00
  • 签到天数: 10 天

    [LV.3]偶尔看看II

    发表于 2012-9-6 17:11 | 显示全部楼层
    奈何col 发表于 2012-9-6 17:08
    是的

    乐乐那是小白呀。。。⊙﹏⊙b汗。。。。。。大神呀。。。。。。明天上课有的看了~~~打发时间到回家试代码
  • TA的每日心情
    郁闷
    2018-12-6 22:21
  • 签到天数: 48 天

    [LV.5]常住居民I

    发表于 2012-9-6 17:15 | 显示全部楼层
    槑小子 发表于 2012-9-6 17:11
    乐乐那是小白呀。。。⊙﹏⊙b汗。。。。。。大神呀。。。。。。明天上课有的看了~~~打发时间到回家试代码 ...

    好好学习天天向上啊~少年
  • TA的每日心情
    无聊
    2017-1-24 10:00
  • 签到天数: 10 天

    [LV.3]偶尔看看II

    发表于 2012-9-6 17:23 | 显示全部楼层
    奈何col 发表于 2012-9-6 17:15
    好好学习天天向上啊~少年

    嗯嗯~~~将来长大建设OJ去~~~
  • TA的每日心情
    无聊
    2017-1-24 10:00
  • 签到天数: 10 天

    [LV.3]偶尔看看II

    发表于 2012-9-7 09:12 | 显示全部楼层
    苦逼的抄了一份还丢了。。。。。。再来抄一份。。。。。。顺便再次支持下
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    热门推荐

    String类型做参数传递时出现问题
    String类型做参数传递时出
    有两个函数,上面这个用来获取数据,然后第70行调用下面的Price_Analyze()来分析数据
    [Arduino物联网开发实战0]开发准备
    [Arduino物联网开发实战0]
    郑重提示:物联网开发,需要你有较好的编程基础,如果你没有编程基础或Arduino开发基
    兩段式水位的程式,要如何寫呢?可以指導一下嗎?
    兩段式水位的程式,要如何
    想請教大大兩段式水位的程式,要如何寫呢?可以指導一下嗎? 兩段式水位 滿水100%時停止
    点灯里面的 定时任务,按指定时间触发 开关 没效果.怎么...
    点灯里面的 定时任务,按
    #define BLINKER_WIFI #include char auth[] = "e9b348c25011"; char ssid[] = "88
    【原创】 drawbot平面关节scara机械臂写字机 画画机器人直播...
    【原创】 drawbot平面关节
    这个项目上个月就在做了,结构和代码反反复复改了多次,加上自己又太忙,一直没来得及
    Copyright   ©2015-2016  Arduino中文社区  Powered by©Discuz!   
    快速回复 返回顶部 返回列表