From linear to exponential PWM output

here the correct code.

That's very redundant. Your problem really is to map a [0..255] value to [0..255] logarithmically. If you need speed, you calculate the logarithmic transformation offline and store that results in a lookup table.

So something like this would be much faster / simpler:

//  ++++  curve section  +++++++
  speedfinalValue = lookupTable[analogReed(sensorspeedPin) >> 2]; //read the sensor and return the highest 8 bits.
  //  ++++  curve section  +++++++

lookupTable[] is also very easy to calculate: for sensor value 0..255, you want the lookupTable to return (255/log(255)) * log(sensor value), other than for sensor value 0, the lookupTable should return 0.

So the table should look like this (using natural base, not 10 base):

0
0
31
50
63
74
82
89
95
101
105
110
114
118
121
124
127
130
133
135
137
140
142
144
146
148
149
151
153
154
156
158
159
160
162
163
164
166
167
168
169
170
172
173
174
175
176
177
178
179
180
180
181
182
183
184
185
186
186
187
188
189
189
190
191
192
192
193
194
194
195
196
196
197
198
198
199
199
200
201
201
202
202
203
203
204
204
205
206
206
207
207
208
208
209
209
210
210
210
211
211
212
212
213
213
214
214
215
215
215
216
216
217
217
217
218
218
219
219
219
220
220
221
221
221
222
222
222
223
223
223
224
224
225
225
225
226
226
226
227
227
227
228
228
228
229
229
229
229
230
230
230
231
231
231
232
232
232
232
233
233
233
234
234
234
234
235
235
235
236
236
236
236
237
237
237
237
238
238
238
238
239
239
239
239
240
240
240
240
241
241
241
241
242
242
242
242
243
243
243
243
244
244
244
244
244
245
245
245
245
246
246
246
246
246
247
247
247
247
247
248
248
248
248
249
249
249
249
249
250
250
250
250
250
251
251
251
251
251
252
252
252
252
252
252
253
253
253
253
253
254
254
254
254
254
255