查看: 3751|回复: 0

[LPC杯海南省大学生电子设计竞赛] 关于X9c104的代码

[复制链接]

该用户从未签到

1

主题

2

帖子

0

新手上路

Rank: 1

积分
9
最后登录
2018-10-18
发表于 2018-10-17 23:15:42 | 显示全部楼层 |阅读模式
在看到的代码,发现烧到板子上时,电位器的滑动部分的电阻并没有改变。感觉是代码的问题,但是不知道哪里错了,求教!

# define INC_pin 2
# define UD_pin 3
# define CS_pin 7
int num=80;
int ud=0
;
int save=1;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  set_X9c104(num,ud,save);

}

void loop() {
  // put your main code here, to run repeatedly:

    }
void set_X9c104(int num,int ud,int save)
{
  digitalWrite(CS_pin,LOW);     //片选使能
  delayMicroseconds(10);        
  if(ud==1)                     //滑动方向选择
  {
     digitalWrite(UD_pin,HIGH);
  }
  else
  {
    digitalWrite(UD_pin,LOW);   
  }
  delayMicroseconds(100);
  for(int i=num;i>0;i--)               //开始向设定方向移动num阶
  {
    digitalWrite(INC_pin,HIGH);
    delayMicroseconds(100);
    digitalWrite(INC_pin,LOW);
    delayMicroseconds(100);
  }
  delayMicroseconds(100);
  if(save==1)                     //是否保存选择
  {
    digitalWrite(INC_pin,HIGH);
    delayMicroseconds(100);
  }
  digitalWrite(CS_pin,HIGH);      
  delay(20);
}

回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /4 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2024-4-20 08:52 , Processed in 0.106261 second(s), 20 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表