int la[9][8]={
{
0,1,1,0,0,0,0,0},{
1,1,0,0,1,1,1,0},{
1,1,1,0,1,0,1,0},{
0,1,1,0,0,0,1,1},{
1,0,1,0,1,0,1,1},{
1,0,1,0,1,1,1,1},{
1,1,1,0,0,0,0,0},{
1,1,1,0,1,1,1,1},{
1,1,1,0,1,0,1,1}};//记录每个数字对应的接口的电位情况int leds[]={
0,1,2,3,4,5,6,7};int a=0,x=0,y=0,h=0;voidsetup(){
// put your setup code here, to run once:for(a=0;a<=7;a++){
pinMode(leds[a], OUTPUT);}}voidloop(){
y=analogRead(A0);//获得A0的模拟值
x=map(y,0,1019,0,8);//转换为1-9
h=map(y,0,1019,0,255);//转换为0-255// put your main code here, to run repeatedly:analogWrite(10,h);//将十号引脚的电压以h输出for(a=0;a<=7;a++){
if(la[x][a]==0){
digitalWrite(a, HIGH);}else{
digitalWrite(a, LOW);}}delay(100);}