• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ read_adc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中read_adc函数的典型用法代码示例。如果您正苦于以下问题:C++ read_adc函数的具体用法?C++ read_adc怎么用?C++ read_adc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read_adc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

void main ()
{
  set_tris_a(0xff);//se pone el puerto RA analogo de entrada
  set_tris_d(0x00);//se pone el puerto RD en salida para prender los led

  setup_adc_ports(ALL_ANALOG);//configuracion de los puertos analogos
  setup_adc(ADC_CLOCK_DIV_32);//el osilador del ADC

  while (true)
  {

    set_adc_channel(0);
    delay_us(10);
    valor = read_adc();
    if(valor){
      output_d(0x01);
    }else{
      output_d(0x00);
    }

    set_adc_channel(1);
    delay_us(10);
    valor = read_adc();
    if{
      output_d(0x02);
    }else{
      output_d(0x00);
    }
  }
开发者ID:cceballosq,项目名称:robotica7A,代码行数:29,代码来源:practica10.c


示例2: main

void main()
{

   setup_adc_ports(ALL_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   // TODO: USER CODE!!
   
      set_adc_channel(0);            // set ref valus
      delay_ms(100);
      ref_0 =read_adc();
      delay_ms(100);
      
      set_adc_channel(3);            // set ref valus
      delay_ms(100);
      ref_3 =read_adc();
      delay_ms(100);
   
   output_b(0b11111111);
   delay_ms(700);
   output_b(0);
   
   while(1){
      set_adc_channel(0);
      delay_ms(20);                        // take readings
      adc_val_0 =read_adc();
      delay_ms(20);
      if(adc_val_0 > ref_0+cons){
         l_0 =1;
         output_high(pin_d7);
         delay_ms(500);
      }
      else{
         l_0=0;
         output_low(pin_d7);
     //    delay_ms(500);
      }
      
      set_adc_channel(3);
      delay_ms(20);                        // take readings
      adc_val_3 =read_adc();
      delay_ms(20);
      if(adc_val_3> ref_3+cons){
         l_3 =1;
         output_high(pin_d6);
         delay_ms(500);
      }
      else{
         l_3=0;
         output_low(pin_d6);
      }
   }
}
开发者ID:isurusanjeewa,项目名称:Line-Following-Robot,代码行数:60,代码来源:2_sen.c


示例3: main

int main(void){

    //    UART_Setup();

    DDRB |= (1<<LED);
    PORTB |= (1<<LED);

    DDRB |= (1<<MB1) | (1<<MC1);

    PORTE |= (1<<SW1C);

    DDRH |= (1<<MA)| (1<<MD);

    ADC_Setup();

    TIM0_Setup();
    sei();

    while(1){
        PORTB ^= (1<<LED);
        _delay_ms(500);

        vrailing=read_adc(TRRAILLING);
        if(vrailing<5){
            vrailing=5;
        }

        vfiller=read_adc(TRFILLER);
        if(vfiller<5){
            vfiller=5;
        }

    }
}
开发者ID:mekatronik-achmadi,项目名称:las_orbit,代码行数:34,代码来源:main.c


示例4: main

void main(void)
{

    usart_init();                        
    adc_init();                                                
    DDRB.3 = 1;


    while (1)
        {        
#if !TEST_MODE
        unsigned int Temperature = read_adc(1);             //Read ADC Channel number 1 (PA1)
        Temperature >>= 1;                                  //Divide the reading by 2 to get the temperature
        printf("Temperature = ");                           //Print the temperature value of the hyper terminal
        printf("%u",Temperature);
        printf("C \n");
        delay_ms(2000);                                     //Wait 2 sec to read the temperature again
        control_motor(Temperature);                         //Control the motor using the Temperature value
#else   
        unsigned int Reading = read_adc(1);                 //Read ADC Channel number 1 (PA1)
        printf("Reading = ");                               //Print the reading
        printf("%d",Reading);
        printf("\n");              
        control_motor_POT(Reading);                         //Control the motor using the Reading value
        delay_ms(100);                                      //Wait 100ms to see the change in motor speed
#endif
        };
}
开发者ID:ArmiaWagdy,项目名称:Temperature-Controlled-DC-Motor,代码行数:28,代码来源:Temperature_Controlled_DC_Motor.c


示例5: temp_probe

int16 temp_probe()
{
   int8 i;
   int16 temp;
   int32 result,reading;
   
   result=0;
   set_adc_channel(1,VSS);
   
   output_bit(PIN_D0, 1);
   
   for(i=1;i<51;++i){
      reading=read_adc();
      delay_ms(5);
   }
   
   for(i=1;i<101;++i){
      reading=read_adc();
      result=(((result*(i-1))+reading)/i);
      delay_ms(5);
   }   
   
   output_bit(PIN_D0, 0);

   temp=((result*4133)/100)-20513;
   
   //printf("%Ld,%Ld,%Lu\r\n",reading,result,temp);

   return(temp);
}
开发者ID:frazahod,项目名称:SUBGEN-NuLAB-EcoLAB-,代码行数:30,代码来源:detector.c


示例6: read_supply

int16 read_supply()
{
   int8 i;
   int16 volts;
   int32 result,reading;
   
   result=0;
   set_adc_channel(0,VSS);
   
   for(i=1;i<51;++i){
      reading=read_adc();
      delay_ms(5);
   }
   
   for(i=1;i<101;++i){
      reading=read_adc();
      result=(((result*(i-1))+reading)/i);
      delay_ms(5);
   }   

   volts=((result*100)/272)+86;
   
   //printf("%Ld,%Ld,%Lu\r\n",reading,result,volts);

   return(volts);
}
开发者ID:frazahod,项目名称:SUBGEN-NuLAB-EcoLAB-,代码行数:26,代码来源:util.c


示例7: getkey

int8_t getkey(void)
{
	uint8_t adcv;
	//uint8_t c = 0;
	for(;;){
		//if(c > 10) return DIR_NONE;
		//c++;
		adcv = read_adc();
		if(adcv < (uint8_t)(256.0*0.5/3.035)) return DIR_UP;
		//if(read_adc() != adcv) continue;
		//if(adcv == 0) adcv = 1;
		//else if(adcv == 255) adcv = 254;
		_delay_ms(1);
		uint8_t adcv2;
		adcv2 = read_adc();
		//if(adcv2 >= adcv - 2 || adcv2 <= adcv + 2) break;
		//if(adcv2 >= adcv - 1 || adcv2 <= adcv + 1) break;
		if(adcv2 == adcv) break;
	}

	//if(adcv < (uint8_t)(256.0*0.6/3.035)) return DIR_UP;
	if(adcv > (uint8_t)(256.0*(1.518-0.2)/3.035) && adcv < (uint8_t)(256.0*(1.518+0.2)/3.035)) return DIR_LEFT;
	if(adcv > (uint8_t)(256.0*(0.976-0.2)/3.035) && adcv < (uint8_t)(256.0*(0.976+0.2)/3.035)) return DIR_RIGHT;
	if(adcv > (uint8_t)(256.0*(2.011-0.2)/3.035) && adcv < (uint8_t)(256.0*(2.011+0.2)/3.035)) return DIR_DOWN;
	return DIR_NONE;
}
开发者ID:Cloudef,项目名称:elladunkku,代码行数:26,代码来源:main.c


示例8: sampling_ADC

void sampling_ADC()
{
  float data[50][6];

  for(int i = 0; i <= 49; i++)
  {
    for(int j = 0; j <= 8; j++)
    {
      if (j==4) //Cambiar a AN8
      {
         j=8;
         set_adc_channel(j);
         delay_us(20);
         data[i][j-3] = read_adc();
   
         printf("%g\t",tconv*data[i][j-3]);
         delay_us(10);
      }
      
      else
      {
         set_adc_channel(j);
         delay_us(20);
         data[i][j] = read_adc();
   
         printf("%g\t",tconv*data[i][j]);
         delay_us(10);
         }
    }
    
    delay_us(10);
    printf("\r\n");
    
  }
}
开发者ID:GeorgeHdez,项目名称:Prog-Adv-PIC,代码行数:35,代码来源:Sensores.c


示例9: main

void main(void)
{
	init();
	while (1)
	{
		mode=datarx;
		if ((mode != 57) & (mode > 48))
		{
			mode1=mode;
		}
		if (mode == 57)
		{
			mode2=mode;
		}
		if (mode1 == 49)
		{
			tv();
		}
		if (mode1 == 50)
		{
			tr();
		}
		if (mode1 == 51)
		{
			datatx((read_adc(1)+1));
		}
		if (mode1 == 52)
		{
			datatx(0);
			tv();
			datatx((read_adc(1)+1));
		}
		if ((mode1 == 53) & (mode2 == 57))
		{
			tv();
		}
		if ((mode1 == 54) & (mode2 == 57))
		{
			tr();
		}
		if ((mode1 == 55) & (mode2 == 57))
		{
			datatx((read_adc(1)+1));
		}
		if ((mode1 == 56) & (mode2 == 57))
		{
			datatx(0);
			tv();
			datatx((read_adc(1)+1));
		}
		mode2=0;
		delay_ms(100);
	}
}
开发者ID:ArdWar,项目名称:Kuliah,代码行数:54,代码来源:Txi.c


示例10: main

 int main()
 {
 	int x,y,z;
	adc_init();

	lcd_init();	delay(100);
	
	data('a');
 	
	while(1) 
	{	cmd(0x01); // Clear LCD
		
		AD0CR = 0x00200600; // ADC Stop, select Channel 0
		AD0CR |= 0x01000000;  // Start ADC, Channel 0
		x = read_adc();
		cmd(0x80);
		dispInt(x);
		
		AD0CR = 0x00200602;
		AD0CR |= 0x01000000;  // Start ADC, Channel 0
		y = read_adc();
		cmd(0x85); 
		dispInt(y);
		
	
		AD0CR = 0x00200604;
		AD0CR |= 0x01000000;  // Start ADC, Channel 0
		z = read_adc();
		cmd(0x8A); 
		dispInt(z);
				  
		if(x>600 )
		{
			cmd(0x01);
			str("ALERT x = ");
			cmd(0xc0);
			dispInt(x);
			delay(1000);
			cmd(0x01);
		}
		if(y<300 )
		{
			cmd(0x01);
			str("ALERT y = ");
			cmd(0xc0);
			dispInt(y);
			delay(1000);
			cmd(0x01);
		}
		delay(100);		

	}
 	
 }
开发者ID:SarathM1,项目名称:LPC2138,代码行数:54,代码来源:multiChannel.c


示例11: get_average_adc

/**************************************************************************
*   Function name : rd_adc
*   Returns :       Результати оцифровки
*   Parameters :    Канал АЦП
*   Purpose :       Оцифровка по указаному каналу і розрахунок середнього арифметичного з 4х вимірів по указаному каналу АЦП
****************************************************************************/
unsigned int get_average_adc(unsigned char adc_input)
{
	//---------------------------------------------------------------------------------------
	unsigned int temp_adc = 0;
	//_delay_us(500);
	temp_adc=read_adc(adc_input);
	_delay_us(10);//_delay_us(50);
	temp_adc=temp_adc + read_adc(adc_input);
	_delay_us(10);//_delay_us(50);
	temp_adc=temp_adc + read_adc(adc_input);
	_delay_us(10);//_delay_us(50);
	temp_adc=temp_adc + read_adc(adc_input);
	temp_adc=temp_adc>>2;
	return temp_adc;
	//---------------------------------------------------------------------------------------
};
开发者ID:vitfre,项目名称:UControl_Module,代码行数:22,代码来源:adc.c


示例12: read_analog

int16 read_analog(int channel)
{
   int i;
   channel &= 0x1F;

   delay_us(2);			   // 2 usec delay
   output_high(MPH_CLK);   // activates SCLK
   output_high(MPH_SYNC);  // activetes SYNC

   delay_us(1);			   // 1 usec delay
   output_low(MPH_SYNC);   // resets SYNC

   for(i=8; i>0; i--)
   {
      if ((channel & (1<<(i-1)))==0)
			output_low(MPH_DIN);
      else
			output_high(MPH_DIN);
      output_low(MPH_CLK);   // resets SCLK
      output_high(MPH_CLK);  // activates SCLK
   }

   delay_us(50);		   // 50 usec delay to stabilize the value.
   return (read_adc());	// reads the analog channel, waits for end of conversion
                        // and returns the value.
}
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:26,代码来源:TestMPH.c


示例13: getchr

uint8_t DeviceCommands::next_command(void)
{
    static char c;
    c = getchr();
    if (c>0)
        put(c);
        if (parse()) {
            if (strcmp(command.name, "echo") == 0)
                echo(command.parameters[0]);
            else if (strcmp(command.name, "set_pwm") == 0)
                set_pwm((uint8_t)command.parameters[0], command.parameters[1]);
            else if (strcmp(command.name, "set_motors") == 0)
                set_motors(command.parameters[0], command.parameters[1], command.parameters[2], command.parameters[3]);
            else if (strcmp(command.name, "set_led") == 0)
                set_led((uint8_t)command.parameters[0], (uint8_t)command.parameters[1]);
            else if (strcmp(command.name, "read_adc") == 0)
                read_adc();
            else if (strcmp(command.name, "stop") == 0)
                stop();

            
            
  //          comm << cp.command.name<<"\t"<<cp.command.nparameters<<"\n";
        }
    return 0;
}
开发者ID:rzoli,项目名称:robot-control,代码行数:26,代码来源:comm.cpp


示例14: read_adc

float Eps::read_bus(){

  float bus = read_adc(0x1F);
  bus = (bus * -5.01841) + 5053.055;
  return bus;

}
开发者ID:atharris,项目名称:cdh,代码行数:7,代码来源:Eps.cpp


示例15: main

void main(void)
{
unsigned char init_result[7],lcd_result[10];
double bss;

ADMUX=ADC_VREF_TYPE & 0xff;    
ADCSRA=0x86;          //initiate AD for 125kHz clock, 8 bit result and AREF pin as voltage reference.

lcd_init(16);   //lcd connect to port D and 16 line mode.

while (1)
      {
        bss=read_adc(5);
        bss=bss*(3.3/256);
        
        lcd_clear();
        lcd_gotoxy(0,0);
        lcd_putsf("voltage is:");
        
        ftoa(bss,2,init_result);
        sprintf(lcd_result,"%4s volt.",init_result);
        
        lcd_gotoxy(0,1);
        lcd_puts(lcd_result);
        
        delay_ms(350);
      }
}
开发者ID:naminic,项目名称:Avr-adc,代码行数:28,代码来源:main.c


示例16: readvis

void readvis(void)
{
    if ((tic & 3) == 0)
    {
        PORTD |= (1 << PORTD5);
        delay_ms(50);
        ad1 = read_adc(0);
    }
    if ((tic & 3) == 2)
    {
        PORTD &= ~(1 << PORTD5);
        delay_ms(50);
        ad0 = read_adc(0);
    }
    tic++;
}
开发者ID:ArdWar,项目名称:Kuliah,代码行数:16,代码来源:Txi.c


示例17: main

void main()
{
   init_pic();

     initialDisplay();
     t = read_adc();

   OUTPUT_HIGH(PIN_C0);
   OUTPUT_HIGH(PIN_C2);
   OUTPUT_LOW(PIN_C3);
       while(1)
       {
       //  if(number_changed)
      //   {
            lcd_display(noOfPeople,14,1);
      //      number_changed = 0;
      //   }
         read_temperature();
         if(temp_changed)
         {
            lcd_display(temperature,13,2);
            temp_changed = 0;
         }

       //  phaseControl();

       }
}
开发者ID:Manuri,项目名称:People-counting-and-fan-speed-controlling-system,代码行数:28,代码来源:testing5_change+fan.c


示例18: scanLine

void scanLine()
{
    unsigned char i = 0;      
    unsigned char adcRead[i];  // Variabel pembacaan nilai ADC          
    // JUmlah warna putih dan hitam yang terdeteksi oleh sensor
    unsigned char blackCount = 0, whiteCount = 0;   
    
    sensor = 0x00;   // Hapus nilai sensor sebelumnya
    
    for (; i<8; i++) {     
        adcRead[i] = read_adc(i);  // Baca nilai ADC ada bit ke-i
        if (adcRead[i] > white)  // Jika hasil pembacaan > nilai putih
            blackCount++;       // Increment jumlah blok hitam yang terbaca
        else 
            whiteCount++;      // Increment jumlah blok putih yang terbaca
    }                   
    if (whiteCount > blackCount) {  // Banyaknya blok warna putih yang terdeteksi > dari blok warna hitam, maka garis nya adalah hitam
        for (i=0; i<8; i++) {
            if (adcRead[i] > white)
                sensor |= (1<<i);
        }                                  
    }
    else { // Banyaknya blok warna putih yang terdeteksi < dari blok warna hitam, maka garis nya adalah putih
        for (i=0; i<8; i++) {
            if (adcRead[i] < black)
                sensor |= (1<<i);
        }
    } 
}
开发者ID:roziqbahtiar,项目名称:ElinfoUGM,代码行数:29,代码来源:main.c


示例19: main

//---------------------------------
   void main()
{  //#byte TRISB=0b11000000;
   SET_TRIS_B(0xC0);    //configura PORTB entrada / 0=salida / 1=entrada
   OUTPUT_D(0x00);   //inicializando PORTD en 0x00
   //#byte PORTB=0x00;
   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);//|RTCC_8_bit);      //51.2 us overflow
  // setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);      //13.1 ms overflow

  // setup_ccp1(CCP_COMPARE_SET_ON_MATCH);

  // enable_interrupts(INT_RTCC);
   enable_interrupts(INT_RTCC);
   enable_interrupts(GLOBAL);
   cont=0;
   comp1=0;

   while(TRUE)
   {

   set_adc_channel(0);
   delay_ms(1);//tiempo  de offset necesario
   comp1=((read_adc())/1024.0*250.0); 
   delay_ms(1);//tiempo  de offset necesario
 
   }

}
开发者ID:JOTAI,项目名称:SistemasEmbebidos2014-I,代码行数:30,代码来源:PWM_Timer.c


示例20: main

int main(void) {

	SETUP_ADC(ADC_CLOCK_INTERNAL);
	SETUP_ADC_PORTS(AN0);
	set_adc_channel(0);

	while (TRUE) {

		if (!input(botStart)) {
			delay_ms(100);
			if (!input(botStart) && !ctrl) {
				ctrl = TRUE;
				cont = 0;
				while (cont < bufferSize) {
					vetor[cont++] = read_adc();
					while (!adc_done())
						;
				}
				for (cont = 0; cont < bufferSize; ++cont) {
					printf("%lu\n\r", vetor[cont]);
				}
				cont = 0;
			} else if (ctrl)
				ctrl = FALSE;
		}
	}
	return 0;
}
开发者ID:cukier,项目名称:Toroide,代码行数:28,代码来源:toroide.c



注:本文中的read_adc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ read_args函数代码示例发布时间:2022-05-30
下一篇:
C++ read_SSSR函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap