Control a speed of a blender

i'm trying to do a blender
my code need to control the speed of a motor

1 push button need to pulse 1 sec on and 1 sec off
1 push button turn of the blender
1 push button control 50% of the motor speed
1 push button control 100% of the motor speed

int led = 2;

byte port[4] = {3, 4, 5, 6};
int press;
int on = 0;



void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);
  pinMode(port[0], INPUT);
  pinMode(port[1], INPUT);
  pinMode(port[2], INPUT);
  pinMode(port[3], INPUT);
  }


void loop() {
  
   
  press = digitalRead(port);
  if(press == HIGH){
    delay(300);
    switch(on){
      case 0:
        analogWrite(led, 255);
        on = 2;
        break;
      case 1:
        analogWrite(led, 255 * 0.5);
        on = 1;
        break;
      case 2:
        analogWrite(led, 0);
        on = 0;
        break;
      case 3:
        analogWrite(led, 255);
        delay(1000);
        analogWrite(led, 0);
        on = 3;
        break;
      default:      
        analogWrite(led, 0);
        on = 0;
        break;
    }     
  }
 }

i'm using a led just for tests but i'll use H bridge l298n or l293d.

my code show this error "warning: invalid conversion from 'byte* {aka unsigned char*}' to 'uint8_t {aka unsigned char}' [-fpermissive]
press = digitalRead(port);
"

You are missing any attempt to measure the speed of the motor. You cannot control the speed unless you can measure the speed. Perhaps you mean to just have a low speed and a high speed and guess at the actual speed. SO VERY much depends on the type of motor in the blender.
Paul

Things are not computing for me. A blender is a digital mixer or an appliance in my way of thinking. The appliance has a line powered motor which the L298 cannot control. By speed what is your accuracy requirement; is it it typical appliance control or more precise? Maybe you should post a schematic, not a frizzy drawing showing all connections including power and ground.

Most mixers have universal motors which can be triac-controlled. However if its not a
universal motor you almost certainly won't be able to control it at all.

If you post full details of the hardware involved, that would answer many questions.

Perhaps in this from op:

i'm trying to do a blender

... "do" means they're trying to build a blender with a dc motor, not control an existing mains driven one?

That's just a guess though; circuit and other details needed as already asked.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.